I'm having an issue with the following situation.
I've souped up a site using pushState for various things and the result is a shockingly responsive web app, but this issue is preventing me from using this.
Here's a sample of the code:
$('a').live('click', function(){
history.pushState({}, '', this.href);
popstate(this.href);
return false;
});
popstate = function(url){
$('#content').load(url);
}
window.onpopstate = function(event){
popstate(window.location.href);
event.preventDefault();
}
Notes:
It seems that some browsers often confuse the partial loaded via ajax and the entire page, decorated with its layout. That's because they both have the same URL. So when the user click on the back button, the browser won't load the URL and will just display the partial it has previously downloaded via ajax.
To avoid this and maintain two separate internal caches (one for the partial page and one for the entire page), you should add a GET parameter in the URL when calling via ajax. Like this in your code:
popstate = function(url){
$('#content').load(url+'?_ajax=1');
}
Hope this helps.
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