Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
517 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 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...