如何使用xii可编辑的回调使用yii扩展名

时间:2014-04-30 18:49:48

标签: javascript php jquery ajax yii

我尝试使用回调。如果数据成功更新,那么我需要显示模态窗口。但它不起作用!请帮忙!我不知道,它是如何工作的。请写信给我。

在视图中

 <?php
    $this->widget('editable.EditableField', array(
    'type' => 'select',
    'params' => array('YII_CSRF_TOKEN' => Yii::app()->request->csrfToken),
    'model' => $model,
    'attribute' => 'category_id',
    'url' => $this->createUrl('course/updateSameInfo'),
    'source' => Editable::source(Coursecat::model()->findAll(), 'id', 'name'),
    'placement' => 'right',
    ));
?>

在控制器中

public function actionUpdateSameInfo()
{
 $es = new EditableSaver('Course'); //'User' is name of model to be updated
 $es->update();
}

1 个答案:

答案 0 :(得分:0)

使用success属性。这是文档http://x-editable.demopage.ru/index.php?r=site/widgets#Options

试试这个

    <?php
    $this->widget('editable.EditableField', array(
    'type' => 'select',
    'params' => array('YII_CSRF_TOKEN' => Yii::app()->request->csrfToken),
    'model' => $model,
    'attribute' => 'category_id',
    'url' => $this->createUrl('course/updateSameInfo'),
    'source' => Editable::source(Coursecat::model()->findAll(), 'id', 'name'),
    'placement' => 'right',
    'success' => 'js: function(response, newValue) {
            console.log(response); //Open the browser console to check the data
        }'
    ));
    ?>