Yii2 Pjax 与 ActionForm ,不刷新提交数据

<?php yii\widgets\Pjax::begin(['id'=>'phoneDetail']);?>

    <?php $form = ActiveForm::begin(
        ['id'=>'queryPhone',
            'method'=>'post',
            'options'=>['data-pjax'=>'#phoneDetail']
        ]
    ) ?>
...
<?php ActiveForm::end() ?>
<?php yii\widgets\Pjax::end();?>

将ActionForm中的Option属性添加 'data-pjax' => ‘pjax ID’即可,我还傻傻的在submitButton中添加'data-pjax‘属性,看到  
https://github.com/yiisoft/yii2/issues/5171 这里我就懂了

附上 controller的对应action部分代码吧

1 return $this->renderAjax('index', [
2                         'dataProvider' => $dataProvider,
3                         'model'=>$data,
4                         'from'=>$from,
5                     ]);

 

posted @ 2016-07-23 20:19  ediszhao  阅读(2668)  评论(0编辑  收藏  举报