I’m building a Backbone.js app that will be fairly complex. Coming from a Rails background, I’m trying to figure out when it’s appropriate to trigger routes (and their functions with the true option), and when to just change application state without affecting the url.
It seems like relying heavily on the routers would be a good direction because I can easily launch the application into any state I’d like. Are there any best practices on this? When I started relying on the navigate method I noticed my views were getting duplicated.
AS mentioned above by Jsonwyatt . His statement “It really depends on the situation” is appropriately correct. Something like state change or state manipulation is generally what I prefer is via views . However in a case for example like where I actually navigate through any Navigation urls I would prefer something like
/home/footo be rendered via backbone router.But when you are actually just stating a model state change like updating a model. You can just do
model.save()instead of driving through a url something like/home/student/1which unnecessarily woulkd render another view . But that might cause you to render another view which could have been done from inside your present view only .For reference Darik bailey had a very good talk on application states and router navigation and maintaning browser history pushstate talk on this. For reference you can go through this link .
dont execute a backbone js route handler from your code