How to change state without triggering statechange in history.js?

Viewed 6124

I am using history.js and I have an event handler

$(window).bind('statechange', function(){
    // Loads the content representing the state via ajax
});

Most content changes are triggered by History.pushState([...]) when the user clicks a link or a button.

But in some cases the content change is managed by javascript directly (i.e. by changing, adding or removing a DOM element) and there is no need to load the content representing the new state via ajax.

Still, I need to push a state and change the url to reflect the new state, should the user hit reload or later want to use the back button etc.

So my question is: How do I push a state but avoid loading the content in some cases? Is there a kind of flag that can be passed to the statechange event handler or can I circumvent it altogether?

1 Answers
Related