To prevent a feedback loop when setting the URL hash (#) programmatically (in contrast to manually changing the URL) I want to disable the hashChange listener temporarily.
How should I change this code to actually disable the hashchange event when updating the hash using $.bbq.pushState(hash)? (code below doesn't work)
hashChangeEnabled : true,
bindHashChange : function(){
var that = this;
$(window).bind( 'hashchange', function( event ) {
if(that.hashChangeEnabled == true){
stateObj = event.getState()
that.stateChangedHandler(stateObj);
}
});
},
updateURL : function(hash){
this.hashChangeEnabled = false; // <--- Look here
$.bbq.pushState(hash);
this.hashChangeEnabled = true;
},