无法读取未定义的CJuiDatePicker yii的属性'fadeIn'

时间:2014-09-02 03:56:27

标签: php yii

我目前正在使用CGridView,它有一个下拉框来更改特定ID的状态。更改下拉值后,它会显示一个带有输入字段的模式,用于选择使用' CJuiDatePicker' Zii提供的扩展。我们的想法是将状态更改日期存储在CGridView中,所有这些都是使用ajax完成的。

我目前面临的问题是所有这些在最初的几次都很好。但是过了一段时间,当我试图从模态弹出窗口中选择日期时,我得到了" 无法读取属性' fadeIn'未定义的"错误。

以下是我使用过的代码: 控制器:

public function actionModalMessage() {
    $id = isset($_POST['id']) ? $_POST['id'] : '';
    $value = isset($_POST['value']) ? $_POST['value'] : '';
    $type = isset($_POST['type']) ? $_POST['type'] : '';

    echo $this->renderPartial('message', array('id' => $id, 'value' => $value, 'type' => $type), false, true);
}

模态视图(message.php):

<?php
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'change-status-form',
    'enableAjaxValidation' => false,
    'action' => Yii::app()->createUrl('statistics/update'),
));
?>

<input name="id" id="RefundCheque_id" type="hidden" value="<?php echo $id; ?>">
<input name="value" id="RefundCheque_value" type="hidden" value="<?php echo $value; ?>">
<input name="type" id="RefundCheque_type" type="hidden" value="<?php echo $type; ?>">

<?php
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
    'name' => 'change_date',
    'options' => array(
        'dateFormat' => 'yy-mm-dd',
    ),
    'htmlOptions' => array(
        "id" => "chagedate",
    ),
));
?>


<input type="submit" class='button blue change_status' value="Update"/>
<?php $this->endWidget(); ?>

谢谢。

1 个答案:

答案 0 :(得分:1)

你加载你的js文件,这是一个问题。这是解决此问题的解决方案:

添加到您的控制器:

   Yii::app()->clientScript->scriptMap["*.js"]=false;
   $this->renderPartial('message', array('id' => $id, 'value' => $value, 'type' => $type), false, true);
   Yii::app()->end();

所以现在你在你的ajax触发时排除了加载js脚本。

现在您需要在初始视图中注册所需的脚本。

Yii::app()->clientScript->registerCoreScript('jquery.ui');

JqueryUI需要使用datepicker小部件。