{"issue":{"title":"PushState Router unnecessarily breaks hash fragment links","milestone":null,"user":{"id":19603,"login":"micheljansen","url":"https://api.github.com/users/micheljansen","avatar_url":"https://secure.gravatar.com/avatar/f492615b8e7853fd6e4cb18f7309b569?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"f492615b8e7853fd6e4cb18f7309b569"},"created_at":"2011-12-20T16:38:25Z","labels":[],"state":"open","updated_at":"2011-12-20T16:43:19Z","id":2614808,"closed_at":null,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"html_url":"https://github.com/documentcloud/backbone/issues/803","body":"Although I understand the history behind the Backbone Router, and I am sure there are scenarios where it is desirable to automatically fall back to hash fragment based URLs when there is no HTML5 PushState support, the current implementation is unexpected and inconsistent with how a normal web app is supposed to behave.\r\n\r\nI am using Backbone.js to progressively enhance a page. In its current form, everything is 100% functional without any JavaScript. The purpose of the Backbone Router in this is to reroute certain actions to AJAX requests rather than page transitions. I am fine with only targeting modern browsers with PushState support (old browsers will just load the page without AJAX, it's a mobile app anyway). However, there are several hash-based fragment links in the page.\r\n\r\nA good example is a link to #top at the bottom of a list of search results. Without Backbone in charge of the browser history, this works fine, but as soon as we turn on the Backbone Router things fall apart in subtle ways. The link to top still works (not triggering a route called \"top\" or \"#top\" in the Router, by the way), and now the \"http://my-path.tld/#top\". If I refresh the page like this, the Router reinterprets this to \"http://my-path.tld/top\" (this time it *does* trigger a route called \"top\"), which brings the app in an inconsistent state. There is no http://my-path.tld/top/ so if the user refreshes the page, bookmarks this URL or sends it to a friend, it results in a 404 error.\r\n\r\nI read the comments on https://github.com/documentcloud/backbone/issues/418 as a kind of \"you're holding it wrong\"-response. I do not believe this is the case. If the Backbone Router operates on real URLs, they should be consistent with the way they are supposed to work without JavaScript and as they are now they don't.\r\n\r\nThere are probably several solutions to this, but the easiest one would be to allow developers to opt in/out of PushState and hashchange separately and not redirect /#top to /top by default.","number":803,"url":"https://api.github.com/repos/documentcloud/backbone/issues/803","comments":1,"assignee":null},"comment":{"user":{"id":4732,"login":"jashkenas","url":"https://api.github.com/users/jashkenas","avatar_url":"https://secure.gravatar.com/avatar/32652ed5b8fbd2ecdb1c78e9ac567b4b?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"32652ed5b8fbd2ecdb1c78e9ac567b4b"},"created_at":"2011-12-20T16:43:19Z","updated_at":"2011-12-20T16:43:19Z","id":3221411,"body":"It would be adding another configuration parameter to the router, but I think you're right ... \r\n\r\nIn the case where:\r\n\r\n * You have a pushState site that's more of a \"website\" than an \"app\".\r\n * You don't care about providing a nice experience to IE users, and are comfortable giving them full-page refreshes.\r\n * You want to use `#hash` to jump around to anchors on the page.\r\n\r\n... then it would make sense to opt-out of the hashchange fallback. ","url":"https://api.github.com/repos/documentcloud/backbone/issues/comments/3221411"},"action":"created"}