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...
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...
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.
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.
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.
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.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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...
What's wrong with the success or complete events?
The
popstatehandler callsloadUrl()to load the page, just like when you click a new link. Further down the callstack, thepjax:successandpjax:completeevents 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.