2014-01-20 23 views
1

工作後,我有:YII MaskedTextField不AJAX加載

視圖 - _form.php

echo CHtml::ajaxLink(CHtml::image('/images/plus.png', ''), 
    $url = CController::createUrl('User/Dynamicreference'), $ajaxOptions=array (
     'type'=>'POST',  
     'success'=>'function(data){ $(body).append(data);}' 
    ) 
); 

而且UserController.php

public function actionDynamicreference(){ 
    $this->widget('CMaskedTextField', array(
     'name' => 'Items[items_reference][]', 
     'value' => '', 
     'mask' => '999999', 
    )); 
} 

面膜輸入不AJAX加載後工作(jQuery的不會在AJAX請求之後執行)。我怎麼解決這個問題?

回答

1

解決方案位於CController.renderPartial()的第四個參數processOutput中。將其設置爲true,您將在您的ajax請求中獲得jquery.maskedinput插件。

//動作

// ... 
if (Yii::app()->request->isAjaxRequest) 
    { 
     $content = $this->renderPartial('content', null, true, true); 
     echo $content; 
     Yii::app()->end(); 
    } 
// ... 

//視圖文件content.php

<?php $this->widget('CMaskedTextField', array('mask'=>'99:99:99','name'=>'someName')); ?>