3 ms·
Nope, that's incorrect. You can opt-in to the "graceful degradation" style of routing by using: Backbone.history.start({ pushState: true, hash
by jashkenas 14y ago
Nope, that's incorrect.
You can opt-in to the "graceful degradation" style of routing by using:
Backbone.history.start({
pushState: true,
hashChange: false
});
... which will route URLs using pushState where available, and will run full-page loads where pushState is not supported.
It's a pretty rare use case for a Backbone app that needs a router, but it's definitely supported.
- manuelflara 14y agoYou just made my day, thank you.
- sophacles 14y agoI am aware of those settings, but they behaved unpredictably last time I tried to use them. They may have improved since. Further, it just plain doesn't handle the case where you want to have hash urls and push-state urls in the same page. [1] The History object is a singleton, so you can't have different routers for different tasks, without getting into the embedded backbone stuff, which is complicated enough that just writing your own router for pushState and keeping the default hash routes for Backbone routers is simpler. [1] Yes I know someone will come along and tell me how horrible my design must be, but here's the thing: hash urls are great for some things, particularly when you DON'T want the server side to know about WTF is happening with internal page state, while at the same time you want to be able to handle the back button nicely. Different tools, different jobs.