Closed sleddd closed 6 years ago
What's wrong with the success or complete events?
The popstate
handler calls loadUrl()
to load the page, just like when you click a new link. Further down the callstack, the pjax:success
and pjax:complete
events should be triggered.
I don't understand the issue. Popstate should trigger the success and complete events. Did you try it and it wasn't triggered?
Please post your code that reproduces the issue, so I can try to debug it.
All I can tell you, is that it does not always trigger with success/complete and reliably works with popstate. Thank you for your help, but I have resolved my issue.
If you use whenDOMReady and try hitting the back button, it won't fire using success | complete. To get whenDOMReady to fire when navigating with history (back | forward), you need to attach an event listener to popstate. (i.e. document.addEventListener('pjax:popstate', function(){ //do stuff });
If you alter the pjax library within the function that handles popstate at about line 53 with: trigger(document,"pjax:popstate", state.options)
Then you will be able to add in your custom code: document.addEventListener('pjax:popstate', whenDOMReady)
It will solve the DOM ready, etc... not firing on history issue.
I would suggest adding the pjax:popstate option...