I'd like to use Backbone's fantastic routing system, but I'd like to NOT have any form of hash support for older browsers. Is it possible to disable hashes entirely when using pushState
in Backbone.History
?
I'd like to use Backbone's fantastic routing system, but I'd like to NOT have any form of hash support for older browsers. Is it possible to disable hashes entirely when using pushState
in Backbone.History
?
2 Answers
Reset to default 7It's not documented on the backbone.js page, but I found it in the annotated source. If you pass hashChange
false to Backbone.history.start()
, backbone will not use the hash fallback.
EG:
Backbone.history.start({hashChange:false, pushState:true})
There's lots of good reasons to support pushState, and not fall back to use of hashes, all while still supporting older browsers (the browser will go to the new url and reload instead of updating with ajax).
There's no built in support for this, if it's important to your app to not work in older browsers you could probably modify your version of Backbone. You could just add something like the following at the start of your DomReady function:
if (window.history && window.history.pushState) {
// main script
} else {
alert("Your browser doesn't support push state and I don't want backwards patibility");
window.location('http://away.from.here');
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745249596a4618597.html
评论列表(0条)