Created
July 13, 2012 21:17
-
-
Save ppworks/3107537 to your computer and use it in GitHub Desktop.
Backbone.js で History.pushState未実装ブラウザでhash fragmentを使わずにそのままのurlを使う
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.App = | |
Models: {} | |
Collections: {} | |
Views: {} | |
Routers: {} | |
init: (options)-> | |
options = {} unless options | |
options.pushState = true | |
options.hashChange = false # don't want to rewrite /pathname to #pathname | |
# override getHash | |
# this can fire backbone router when url doesn't has hash fragment | |
Backbone.history.getHash = -> | |
if window.location.search | |
search = window.location.search | |
else | |
search = '' | |
return window.location.pathname | |
if Backbone.history && !Backbone.History.started | |
Backbone.history.start(options) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment