backbone marionette - displaying a view in a layout region which has already been rendered

Posted by Justin Wyllie on Stack Overflow See other posts from Stack Overflow or by Justin Wyllie
Published on 2013-07-03T11:03:25Z Indexed on 2013/07/03 11:05 UTC
Read the original article Hit count: 340

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

© Stack Overflow or respective owner

Related posts about backbone.js

Related posts about backbone.marionette