0

Is there any way to stop # from appearing inside the address bar when using Backbone routing, pushState or not?

gsklee
  • 4,774
  • 4
  • 39
  • 55

2 Answers2

0

@Kay, your Babckbone app should work correctly in all major browsers, and IE8-9 are still widely used (and yes, unfortunately even IE6-7). Using hashes and no pushState is more reliable and lots of huge apps use them (e.g. Facebook). The problem is, if you use hard-coded routes in your links, and they are not hashes, than you're screwed if pushState does not work in a browser. So you either have to use pushState AND use normal pathnames in links that should be picked up by router, or DO NOT use pushState and use hashes. Latter is more preferable IMO.

mvbl fst
  • 5,213
  • 8
  • 42
  • 59
0

Current versions of IE do not support pushState. (It appears in the IE10 previews).

Your options are either to drop down to normal (non-Ajax) links / form submissions / etc, or use the hashbang hack.

I don't know backbone well enough to say for sure, but the following might be sufficient to fallback to normal routing:

if (window.history && window.history.pushState) {
    Backbone.history.start({pushState: true});
}
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335