backbone icon indicating copy to clipboard operation
backbone copied to clipboard

PushState not working with parameters

Open Qvanstraten opened this issue 12 years ago • 1 comments

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.

Qvanstraten avatar Sep 12 '14 22:09 Qvanstraten

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/

NickNaso avatar Sep 15 '14 08:09 NickNaso