title: Yii2: Replace default confirmation message used by Gridview with Sweet alert
body: <p>I am using <a href="https://github.com/yii2mod/yii2-sweet-alert" rel="nofollow noreferrer">yii2mod/yii2-sweet-alert</a> in my projects, I am using it on basic and advanced themes, and I love it.</p>
  
  <p><strong>The question.</strong>
  How can I change the grid default confirmation dialog that is a plain javascript confirmation in order to use <a href="https://sweetalert.js.org/guides/" rel="nofollow noreferrer">Sweet-alert</a> to make it look better?</p>
  
  <p>I already tried modifying the button's template for the delete, because if you want to change the message you will do the following:</p>
  
  <pre><code>        [
              'class' =&gt; ActionColumn::className(),
              'template' =&gt; '{update}{delete}',
              'buttons' =&gt; [
                  'delete' =&gt; function($url, $model){
                      return Html::a('&lt;span class="glyphicon glyphicon-trash"&gt;&lt;/span&gt;', ['delete', 'id' =&gt; $model-&gt;id], [
                          'class' =&gt; '',
                          'data' =&gt; [
                              'confirm' =&gt; 'Are you absolutely sure ? You will lose all the information about this user with this action.',
                              'method' =&gt; 'post',
                          ],
                      ]);
                  }
              ]
          ]
  </code></pre>
  
  <p>But I haven't been successful on changing the confirmation message from the javascript one to sweet alert.</p>
  
  <hr>
  
  <p>Also I am trying as a second option, to make it work with <a href="http://demos.krajee.com/grid#action-column" rel="nofollow noreferrer">Krajee/ Grid and actionColumn</a> but still can make it work «this is the second option am working, to do this».</p>
  
  <pre><code>        [
              'class' =&gt; 'kartik\grid\ActionColumn',
              'viewOptions' =&gt; ['hidden' =&gt; true],
              'updateOptions' =&gt; ['title' =&gt; 'Edit events', 'data-toggle' =&gt; '??'],
              'deleteOptions' =&gt; ['title' =&gt; 'delete your event', 'data-toggle' =&gt; 'I am Lost here'],
          ],
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/WQT9e.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WQT9e.png" alt="from classic to sweet alert"></a></p>
  
  <p>Please any idea on how to change this behavior?</p>
  
  <hr>
  
  <p><strong>MORE ON HOW TO SOLVE IT</strong> - <em>thanks to</em> <a href="https://stackoverflow.com/users/3731614/muhammad-omer-aslam"><strong><code>@muhammad-omer-aslam</code></strong></a></p>
  
  <ol>
  <li><p>create a js file on your public folder, in my case<br>
  <strong><code>/backend/web/js/confirmSwal.js</code></strong> and add the provided code:</p>
  
  <p>Add these lines</p>
  
  <pre><code>yii.confirm = function (message, okCallback, cancelCallback) {
      swal({
          title: message,
          type: 'warning',
          showCancelButton: true,
          closeOnConfirm: true,
          allowOutsideClick: true
      }, okCallback);
  };
  </code></pre></li>
  <li><p>Add this to your AppAssets on </p>
  
  <p><code>/backend/assets/AppAssets.php</code></p>
  
  <pre><code>public $js = [
      '/js/confirmSwal.js',
  ];
  </code></pre></li>
  <li><p>And that's it it works beautiful.</p></li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/S9xQE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S9xQE.png" alt="enter image description here"></a></p>
  
  <p>Thanks again to Muhammad.</p>