Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm designing a module-based intranet system using backbone.js and I basically use the following algorithm on document load.</p> <ul> <li>Create appController, the singleton controller for the app. </li> <li>The appController creates the mainView, this is the view responsible for rendering the skeleton of the page and handling clicks for persistent items on the page (login/logout buttons, etc)</li> <li>The mainView creates a number of childViews for the different parts of the page, navigation, breadcrumbs, header, toolbar, contentContainer, etc. These are the fixtures of the application and they don't change, although their respective content does. The contentArea in particular can contain any layout.</li> <li>The appController runs through the registered modules, initiating the mainModuleController for each of them. These all have namespaces routing schemas.</li> <li>Backbone.history.start()</li> </ul> <p>The moduleControllers all gain access to the appController on init. When catching a hash-location, they send a pageChange event to the appController containing a pageManifest object. The pageManifest object contains all the information needed to set the respective views, such as breadcrumbs info, header info, and most importantly, a reference to an instantiated contentView. The appController uses the information in the pageManifest to setup the different persistent views, deletes the former contentView in the contentContainer and inserts the contentView provided by the module into the container.</p> <p>This way, different designers can work on different modules and all they have to know is the specification of the pageManifest object and how the contentView should look. They can set up complex routing systems of their own, use their own models and customized contentViews (though we plan to have a library of listViews, objectViews, etc to inherit from).</p> <p>We're at the design phase right now, so I can't really guarantee that this is the design we'll finally use or that we don't find any holes in it, but conceptually, we think it's sound. Comments?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload