<?php yiiwidgetsPjax::begin(['id'=>'phoneDetail']);?> <?php $form = ActiveForm::begin( ['id'=>'queryPhone', 'method'=>'post', 'options'=>['data-pjax'=>'#phoneDetail'] ] ) ?> ... <?php ActiveForm::end() ?> <?php yiiwidgetsPjax::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 ]);