not working javascript with Pjax

JavaScript not working after Pjax.


<!DOCTYPE html>

<html lang="<?= Yii::$app->language ?>">

<head>

</head>

<body>

//------Pjax---------

 ....  NavbarAsset::register($this);

 ....  container PHP

//------Pjax---------


</body>

</html>

Я use jQuery.

js


$('.lort').hover(

         //навели

         function () {

             navbar_button_alpha($item_a);

             console.log("Навели ");

         },

         //убрали

         function () {

            console.log(" Убрали ");

         }

    );

Try this instead:




$('body').on('hover', '.lort', function() {

    ...

});



We should not attach an event handler to the element(s) inside the pjax area that is to be updated by ajax call.

Not working.

Could you give us a little more information?

Just saying “Not working” won’t help you any further.

If use Pjax, need use for loading js scripts it:


$(document).on('ready pjax:success' , function () {


 //.......


  CODE


 //........

});

Thanks You. :rolleyes:

And where and when are you loading the "$(.lort).hover" part of the script?