0

After the ajax call my new elements which are created are not recognized by the event handlers in my jQuery code.

Is there a way to reload the JS file when the ajax URL is called?

0

1 Answer 1

0

If you mean that your click events are not being picked up on newly created elements you can use event delegation. Meaning there is no need to reload a whole JS file.

So rather than creating an event binding like so:

$( ".example" ).on( "click", function( event ) {
    ...
});

You attach it to a parent element like so:

$( ".examples-parent" ).on( "click", ".example", function( event ) {
    ...
});
1
  • No my product gallery and tabs are not working in my quickview after I retrieve products with my ajax request Jun 19, 2018 at 9:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.