title: yii2 -> Modal Dialog on Gridview's update button does not work after searching or change pagination on gridview
body: <p>Reference to 
  <a href="https://stackoverflow.com/questions/28470166/yii2-modal-dialog-on-gridview-view-and-update-button-shows-same-content-for-both">Yii2 Modal Dialog on Gridview view and update button shows same content for both buttons</a>
  and 
  <a href="https://stackoverflow.com/questions/28358398/how-to-implement-yii2-modal-dialog-on-gridview-view-and-update-button">How to implement Yii2 Modal Dialog on Gridview view and update button?</a></p>
  
  <p>I got modal dialog from clicking update button on gridview with correct ID parameter from selected row. But when i used searching and pagination on gridview the problem occurred. The modal dialog seem not working anymore the modal dialog will be shown from clicking update button but the ID parameter does not match the selected row. To be honest, it seem gridview does not know the registerJS anymore. Can anyone kindly advise how to solve the problem?</p>
  
  <pre><code>  &lt;?php
  $gridColumns = [
         [
              //'class' =&gt; 'kartik\grid\EditableColumn',
             'attribute' =&gt; 'branch_id',
             'pageSummary' =&gt; true,
         ],
         [
          'class' =&gt; 'kartik\grid\ActionColumn',
          'template' =&gt; '{update} {delete}',
          'headerOptions' =&gt; ['width' =&gt; '20%', 'class' =&gt; 'activity-view-link',],
          'contentOptions' =&gt; ['class' =&gt; 'padding-left-5px'],
  
          'buttons' =&gt; [
              'update' =&gt; function ($url, $model, $key) {
                  return Html::a('&lt;span class="glyphicon glyphicon-star-empty"&gt;&lt;/span&gt;','/branches/update?id='.$key.'', [
                      'class' =&gt; 'activity-view-link',
                      'title' =&gt; Yii::t('yii', 'Update'),
                      'data-toggle' =&gt; 'modal',
                      'data-target' =&gt; '#activity-modal',
                      'data-id' =&gt; $key,
                      'data-pjax' =&gt; '0',
  
                  ]);
              },
          ],
  
  
      ],
  ];?&gt;
  
  &lt;?php Pjax::begin(); ?&gt;
  &lt;?php
  echo GridView::widget([
  
      'dataProvider' =&gt; $dataProvider,
      'filterModel' =&gt; $searchModel,
      'columns' =&gt; $gridColumns,
      // 'containerOptions' =&gt; ['style'=&gt;'overflow: auto'], // only set when $responsive = false
      'headerRowOptions'=&gt;['class'=&gt;'kartik-sheet-style'],
      'filterRowOptions'=&gt;['class'=&gt;'kartik-sheet-style'],
      'pjax' =&gt; true, // pjax is set to always true for this demo
      'pjaxSettings'=&gt;[
          'neverTimeout'=&gt;true,
          'beforeGrid'=&gt;'Branches Data',
          'afterGrid'=&gt;'My fancy content after.',
          'enablePushState' =&gt; false,
          'options' =&gt; ['id' =&gt; 'BranchesGrid'],
      ],
      'bordered' =&gt; true,
      'striped' =&gt; true,
      'condensed' =&gt; true,
      'responsive' =&gt; true,
      'hover' =&gt; true,
      'floatHeader' =&gt; true,
      'panel' =&gt; [
          'type' =&gt; GridView::TYPE_PRIMARY
      ],
  ]);
  ?&gt;
  &lt;?php yii\widgets\Pjax::end() ?&gt;
  
  &lt;?php $this-&gt;registerJs(
  '
  $(".activity-view-link").click(function(e) {
              var fID = $(this).closest("tr").data("key");
              $.get(
                  "update",
                  {
                      id: fID
                  },
                  function (data)
                  {
                      $("#activity-modal").find(".modal-body").html(data);
                      $(".modal-body").html(data);
                      $("#activity-modal").modal("show");
                  }
              );
          });
  
  '
  </code></pre>
  
  <p>); ?></p>
  
  <pre><code>&lt;?php Modal::begin([
  'id' =&gt; 'activity-modal',
  'header' =&gt; '&lt;h4 class="modal-title"&gt;Branches Updatez&lt;/h4&gt;',
  'size'=&gt;'modal-lg',
  'footer' =&gt; '&lt;a href="#" class="btn btn-primary" data-dismiss="modal"&gt;Close&lt;/a&gt;',
  </code></pre>
  
  <p>]); ?></p>