I use pjax. How can I make the script work after each change of content?

    1 answer 1

    $(document).on('pjax:success', function() { $('#loading').show() }) 

    {projec root} /vendor/bower/yii2-pjax/README.md

    if you have a lot of js code, then it should be placed in a separate file and connected via asset. But if literally a couple of lines come up with this option, for a view as an example.

     $js=<<<JS $(document).on('pjax:success', function() { $('#loading').show() }) JS; $this->registerJs($js); /* если это происходит в контроллере, то $this->view->registerJs($js); */ 
    • and this code needs to be written in view or in a regular file that I connect to appassets? - Diefair