Php listview中的yii2 pjax分页失败

Php listview中的yii2 pjax分页失败,php,pagination,yii2,Php,Pagination,Yii2,我有一个listview,我希望使用pjax进行分页,但是分页无法使用pjax 这就是我尝试过的 <?php Pjax::begin([ 'id' => 'w0', //checked id on the inspect element 'enablePushState' => true // i would like the browser to change link ]); ?&g

我有一个listview,我希望使用pjax进行分页,但是分页无法使用pjax

这就是我尝试过的

<?php Pjax::begin([
                'id' => 'w0', //checked id on the inspect element

                'enablePushState' => true  // i would like the browser to change link
            ]); ?>

<?= ListView::widget([
                'summary' => false,
                'dataProvider' => $dataProvider,
                'emptyText' => "",//Yii::t('app', 'Sorry we have no items currently.'),
                'itemOptions' => ['class' => 'item'],
                'options' => ['data-pjax' => true ], //this is for pjax
                'layout' => '{items}{pager}',
                'pager' => [
                    'firstPageLabel' => 'First',
                    'lastPageLabel' => 'Last',
                    'maxButtonCount' => 5,
                    'options' => [
                        'class' => 'pagination col-xs-12'
                    ]
                ],
       'itemView' => function ($model, $key, $index, $widget) {

       return $this->render('_items_list', ['model' => $model]); //This shows one model 
                },
            ]) ?>

 <?php Pjax::end(); ?>


当我单击项目nothing hapens时,当我删除pjax打开和关闭标记时,它与正常页面刷新一起工作,我还需要添加什么

您已经接近解决方案了

<?php Pjax::begin([
    'id' => 'w0', // checked id on the inspect element
    'enablePushState' => true  // I would like the browser to change link
    'timeout' => 10000 // Timeout needed
]); ?>

我只添加了一行:
'timeout'=>10000
。默认情况下,
timeout
等于
1000
(1秒)。因为在那个1秒内并没有返回结果,所以浏览器使用普通页面刷新而不是Pjax。通过将
1000
替换为
10000
,您获得响应的时间将多出10倍(不需要那么长,只是以防万一)。现在Pjax已经足够从服务器检索结果并更新
ListView
,而无需重新加载页面


若您仍然什么也并没有得到,那个么很可能是服务器端的错误。检查网络(在浏览器中)以查看服务器返回的内容(应返回状态200)。

您已接近解决方案

<?php Pjax::begin([
    'id' => 'w0', // checked id on the inspect element
    'enablePushState' => true  // I would like the browser to change link
    'timeout' => 10000 // Timeout needed
]); ?>

我只添加了一行:
'timeout'=>10000
。默认情况下,
timeout
等于
1000
(1秒)。因为在那个1秒内并没有返回结果,所以浏览器使用普通页面刷新而不是Pjax。通过将
1000
替换为
10000
,您获得响应的时间将多出10倍(不需要那么长,只是以防万一)。现在Pjax已经足够从服务器检索结果并更新
ListView
,而无需重新加载页面

若您仍然什么也并没有得到,那个么很可能是服务器端的错误。检查网络(在浏览器中)以查看服务器返回的内容(应返回状态200)