Yii2, GridView, bind registerJs only once
<p>I created new GridViewExtended class using GridView. Then I need register only once pjax events. Simple example...</p>

<pre><code>    &lt;?php Pjax::begin(); ?&gt;
    &lt;?= GridViewExtended::widget([])
    &lt;?php Pjax::end(); ?&gt;
...
&lt;?php
$this-&gt;registerJs('
    $(document).ready(function(){
        $("#w0").on("pjax:click", function() {
            $("#w0 .box").append($("&lt;div class=\"overlay\"&gt;&lt;i class=\"fa fa-refresh fa-spin\"&gt;&lt;/i&gt;&lt;/div&gt;"));
        });

        $("#w0").on("pjax:complete", function(contents,options) {
            $("#w0 .box .overlay").remove();
        });

        $("#w0 .box .overlay").remove();
    });'
);
?&gt;
</code></pre>

<p>So i want this js was registered in GridViewExtended class. If I redefine GridViewExtended::run() and register it there, this js applies on each call (in frontent).</p>

<p>Mean that on fist click (for example pagination) it will be called once, on second twice... And this brokes whole logic. </p>

<p>Ofcourse it works if I register it on view, but I want register it in GridViewExtended.</p>

<p>Please help.</p>