Skip to content

Instantly share code, notes, and snippets.

@ppworks
Created July 21, 2012 11:07
Show Gist options
  • Save ppworks/3155466 to your computer and use it in GitHub Desktop.
Save ppworks/3155466 to your computer and use it in GitHub Desktop.
pushState未サポート時にhash fragmentを使わない設定
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)
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