I have lots of page ajax request on my site. I am using jquery hashchange plugin to integrate them.
Now, as I have observed, after I do $(window).hashchange I always have to re-init some other plugins (e.g. fullcalendar, tooltip, and etc.).
I've been trying to google - on how to prevent re-init during ajax request. I've tried it using live and it works but the problem is there are certain plugins that wont need to use .live function especially when it's content-based (e.g. fullcalendar, tooltip (page load), etc.). I've been trying to solve this issue by using:
$(window).on("hashchange")
I can test if the elements exist and RE-INIT THE PLUGINS (which is so dirty for me), and the problem: the plugins wont work/read.
What would be the best approach in initializing plugins once everytime you do it in ajax? Is that even possible?
P.S. still beginning to learn and explore more on ajax.
From what I understand, you want to initialize plugins loaded via AJAX calls on your page. If that's right, you can put in your plugin initialization code in the "success" callback of your AJAX call.
You only need to add the code for the plugins that need explicit initialization.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With