Skip to content

Instantly share code, notes, and snippets.

@ppworks
Created July 13, 2012 21:17
Show Gist options
  • Save ppworks/3107537 to your computer and use it in GitHub Desktop.
Save ppworks/3107537 to your computer and use it in GitHub Desktop.
Backbone.js で History.pushState未実装ブラウザでhash fragmentを使わずにそのままのurlを使う
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