Yes, sections of children should always be called after the parent has been created, it does not matter if it was accessible by a direct URL or through navigation on the router.
My workaround for this is always the main view in my applications, and the router always calls this main view. The router does not have access to other views. In my main view, I could handle the case when a parent view is created or not.
Example, check how the router only calls MainView, and there I have a method called validateCategories that creates the parent view, if necessary:
var MainView = Backbone.View.extend({ id : 'mainView', categories : null, events : { }, initialize : function(){ _.bindAll(this); }, openSection : function(section){ switch(section){ case 'categories': this.validateCategories(); break; case 'products': this.validateCategories(); this.categories.open( new ProductsView() ); break; } }, validateCategories : function(){ if( !this.categories ){
Also, if you start from scratch, a new project do not forget to look at this extension, which will help you organize Backbone.js projects: https://github.com/derickbailey/backbone.marionette
source share