I tried something like the following but if the page I'm loading has javascript it's not running because the elements are created after page load. When the javascript is something I wrote I simply call the function again after load() and it's ok, but what can I do for the plugins the page has? Like contact forms etc?

Whats is the correct way doing ajax calls in wordpress so as my rest javascript wont brake?
Thanks!

1 Answer
1

Because the DOM is changed, the elements that were removed had their events attached on them removed also, so you need to run that javascript again on the new elements. And if you have no control over those plugins and their javascript, then you'll have to do this the ugly way. This means that you need to search for <script> tags inside the ajax response and inject them in the document.