Skip to content

Instantly share code, notes, and snippets.

@fredsterss
Forked from johnkpaul/app.js
Created December 7, 2012 22:51
Show Gist options
  • Save fredsterss/4237180 to your computer and use it in GitHub Desktop.
Save fredsterss/4237180 to your computer and use it in GitHub Desktop.
IE9- and Backbone.history's pushState
//in your application, rather than using window.location to get the current url
App.getLocation = function(){
return window.location.protocol + '//' + window.location.host
+ '/' + Backbone.history.options.root + Backbone.history.getFragment()
}
//when your application starts up
Backbone.history.start({
pushState: Modernizr.history,
silent: true
});
if (!Modernizr.history) {
rootLength = Backbone.history.options.root.length;
fragment = window.location.pathname.substr(rootLength);
search = window.location.search;
return Backbone.history.navigate(fragment + search, {
trigger: true
});
} else {
return Backbone.history.loadUrl(Backbone.history.getFragment());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment