Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
508 views
in Technique[技术] by (71.8m points)

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

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.

question from:https://stackoverflow.com/questions/65949064/browser-back-and-forward-buttons-behave-weird-when-using-pjax-in-yii2

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...