backbone
backbone copied to clipboard
PushState not working with parameters
I have a problem with pushState enabled. When I go to a url/view/1 nothing works and I just get a load of errors in the console. if I just use the URL with hashtag i.e. url/#view/1 all is fine
Am I forgetting something?
routes: {
'': 'index',
'index': 'index',
'view/:id': 'view',
},
In my console I just get 20 or so errors saying: Uncaught SyntaxError: Unexpected token < on line one.
Read documentation (http://backbonejs.org/#Router) to enable pushState on Backbone.js router. You do not only add: Backbone.history.start({pushState: true}), but you have to handle the routes by the server. You can find more article on the web that explain that: http://artsy.github.io/blog/2012/06/25/replacing-hashbang-routes-with-pushstate/