通过 AJAX 更新内容时,renderPartial.CJuiDatePicker 未正确加载。单击其字段日历时不会出现。
请帮助解决这个问题。
控制器代码:
public function actionEditTestAjax()
{
$Okstatus = 0;
$id = (int)$_POST['ID'];
$newPerson = $this->loadModel($id);
$newPerson = $this->loadModel( $id )->person;
if(isset($_POST['Person']))
{
$newPerson->attributes=$_POST['Person'];
if($newPerson->save())
$Okstatus = 1;
}
Yii::app()->clientscript->scriptMap['jquery.js'] = false;
echo CJSON::encode( array(
'status' => 'OK',
'div' => $this->renderPartial( 'editAjax', array(
'person' => $newPerson),
true, true ),
));
exit;
}
查看代码:
<div class="form">
<?php
$form=$this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id'=>'person-form-edit_person-form',
'type'=>'horizontal',
'enableAjaxValidation'=>false,
'htmlOptions'=>array(
'onsubmit'=>"return false;",/* Disable normal form submit */
'onkeypress'=>" if(event.keyCode == 13){ send(); } " /* Do ajax call when user presses enter key */
),
)); ?>
<fieldset style="position: relative;">
<legend> <?php echo Yii::t('Employee', 'Personal information'); ?> </legend>
<div class="control-group">
<?php echo $form->labelEx($person,'birthDate',array('class'=>'control-label')); ?>
<div class="controls">
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'model'=>$person,
'attribute'=>'birthDate',
'value'=>Yii::app()->dateFormatter->format(Yii::app()->locale->dateFormat, $person->birthDate),
'language' => Yii::app()->language,
// additional javascript options for the date picker plugin
'options'=>array(
//'showAnim' => 'fold',
'showAnim'=>'fold',
'changeMonth' => 'true',
'changeYear' => 'true',
'showOtherMonths' => 'true',
'selectOtherMonths' => 'true',
'showOn' => 'both',
'buttonImage' => '/images/calendar-view-month.png',
'buttonImageOnly' => 'true',
'yearRange' => 'c-100:c'
),
'htmlOptions' => array(
'size' => 10,
'maxlength' => 10,
),
));
?>
</div>
<?php echo $form->error($person,'birthDate'); ?>
</div>
</fieldset>
<div class="form-actions">
<?php echo CHtml::Button('SUBMIT',array('onclick'=>'send();')); ?>
</div>
<?php $this->endWidget(); ?>
</div>
*
但是 CJuiDatePicker 日历没有显示
.*