Browser back and forward buttons behave weird when using pjax in yii2

265 Views Asked by At

I am using pjax in my gridview to not append search query parameters in url. Here is my code for view

 <?php Pjax::begin(['id' => 'pjax_one',
                'timeout' => false,
                'enablePushState' => false, 
                'clientOptions' => ['method' => 'get']
                ]) ?>
            <?=
            GridView::widget([... rest code is here]);
            ?>
  <?php Pjax::end() ?>

In controller:

public function actionIndex() {
    $searchModel = new UserSearch();
    $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
    return $this->render('index', [
                'searchModel' => $searchModel,
                'dataProvider' => $dataProvider
    ]);
}

This code working fine. But using this code browser back and forward buttons behave weird, it redirect to some other page instead of previous page.

If I do 'enablePushState' => true, then it append query parameters to the url, which I do not want to append for the security reason.

Edit: This is happening when I am visiting any page using link or button available in gridview.

0

There are 0 best solutions below