Marcin
Marcin

Reputation: 185

Backbone.js with Rails routing

I have backbone view that navigates url to localhost:3000/about but when i do realod page, Rails routing takes care of routing and redirects me to rails page, not Backbone view. I was reading some tutorials about backbone routing, for example: http://www.codeproject.com/Articles/803073/BackBone-Tutorial-Part-Understanding-Backbone-js-R but anything i do, it doesn't work. Is it even possible to route page after reload to correct backbone view, as it is easy for Rails?

Upvotes: 0

Views: 84

Answers (1)

Trace
Trace

Reputation: 18869

It is normal. When the route is hit, your backend router will fetch and return the corresponding rails view if the router is configured to do so.
When the page is loaded into the browser, only at this moment the backbone router should be instantiated.
By default, Backbone uses hashtags# to route, but by instantiating the router with pushstate:true, you can fetch templates from the backend without losing front end state in your application.

Upvotes: 1

Related Questions