tbranyen/backbone.layoutmanager — Issue #55: Using more than one Route in an application
Author: tvpmb
Created: 2012-02-29 19:23:40+00:00
State: open

@tbranyen: This is probably a higher level application design question. Do you have any examples of using multiple Routes inside an application and specifically avoiding calling `render()` inside each route? Imagine an HR application with a few sections: Employees, Payroll, Document, Complaints.

Each section is somewhat unrelated and would have a different interface, aside from perhaps a master navigation menu. From what I'm understanding right now, the best way to implement this would be to have a single module, since the application's container (index.html) would have all the h5bp + navigation menu. Each of the 4 major sections would get their own Routes.

Here's where the problem comes in. If I have 5 routes, (4 + 1 for the "/" index)...each route has to call `.render()`, because if the user is on any of those sections and they hit refresh in the browser, it would need to be able to re-render the whole page state at the given point of the route.

However, if the user is just using the application, and clicks from Employees to Payroll, it will also cause a re-render, but this is where I don't think it should / don't want it to.

This leads me to the conclusion that to have an app that doesn't re-render when the user navigates, everything in the entire app has to be in a single Router with a single Route.

Is there way to avoid the call to render the whole application? The layoutmanager-example application doesn't really expose this problem, since it is by nature a single page application, with no route navigation. I feel like this is absolutely BEGGING for a nested route manager or something!

I don't completely grasp right now how the Router works, but lets say you clicked from Employees to Complaints in the application. Would the Router not render the entire application if the render had already been called by the Employees route?