Pjax GridView: refresh page after delete

Comparing #1 with #5

Title

how does pjax of delete button in gridview work wellPjax GridView: refresh page after delete

Tags

ajax button in CGridView,pjax,pjax gridview delete refresh

Content

Normally, after clicking the delete button in gridview, the record will be deleted and the page will refresh, but the page number in query string is lost. This is not always what we wanthe case we expect. How to refresh current page with pjax after deleting the record? It seems there is no very simple solutions, This is my way, it works well, although it is not clean
 
 
    
.
 
 
1. Controller file  
 
   ```

public function actionDelete($id)
{
[...]
return $this->redirect(['index']);
}

 
 ```
 
 
2. index.php (view文件:)
 
 file)
 
 
   ```
 
   
<?php
$this->registerJs("
$(document).on('ready pjax:success', function() {
[...]
});
");
   ?>    <?php Pjax::begin(['id' => 'my_pjax']); ?>
<div class="shop-index">
<?= GridView::widget([
[...]
]); ?>
</div>
   <?php Pjax::end(); ?>    ```