Created
July 21, 2012 11:07
-
-
Save ppworks/3155466 to your computer and use it in GitHub Desktop.
pushState未サポート時にhash fragmentを使わない設定
This file contains hidden or 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) |
This file contains hidden or 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: function(options) { | |
if (!options) { | |
options = {}; | |
} | |
options.pushState = true; | |
options.hashChange = false; | |
Backbone.history.getHash = function() { | |
var search; | |
if (window.location.search) { | |
search = window.location.search; | |
} else { | |
search = ''; | |
} | |
return window.location.pathname; | |
}; | |
if (Backbone.history && !Backbone.History.started) { | |
return Backbone.history.start(options); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment