backbone marionette - displaying a view in a layout region which has already been rendered
- by Justin Wyllie
I have something like this:
//render the layout
Layout.layout = new Layout.Screen();
MyApp.SomeRegion.show(Layout.layout);
//render a view into it
var mView = new CompositeView({collection: data});
Layout.layout.SomeRegion.show(mView);
That all works fine.
The layout has 3 regions. The above has rendered a view into one of them.
Now, later, I want (in response to some user interaction) to render another view into one of the other regions. So I try:
var mView2 = new CompositeView({collection: data});
Layout.layout.SomeOtherRegion.show(mView);
But 'SomeOtherRegion' no longer exists on Layout.layout.
I looked at this in Firebug. In the first case Layout.layout has my three regions defined on it. In the second case, not. Though they are still there in the regions object. This is the same layout instance.
It looks like once a layout has been rendered you cannot render into it again? There must be a way.
Nb. I don't want to re-render the layout.
I hope that makes sense
--Justin Wyllie