jeudi 9 avril 2015

HTML5 history storing only one state

I am developing a Google Maps AJAX-application in JS/PHP and want to implement HTML5 History API. I already implemented custom deeplinks so everything can be accessed with pretty URLs.


Now on AJAX get, I do the following to store history:



var stateObj = { id: obj.id };
history.pushState(stateObj, null, obj.deeplink);


and to retrieve it on browser back, I do:



window.onpopstate = function(event) {
google.maps.event.trigger(markersArray[JSON.parse(event.state.id)], 'click');
};


However, only 1 step back is stored, so when I click back multiple times, it calls the same as when calling the first back.


What's wrong?


Aucun commentaire:

Enregistrer un commentaire