James
James

Reputation: 29

Layout inside Layout in Marionette

I have two layouts like:

Layout1 = Marionette.Layout.extend({
  template: {
  type: 'handlebars',
  template: Layout1template
},
  regions: {
  region1: '#header',
  region2: '#content'
}

});

Layout2 = Marionette.Layout.extend({
template: {
  type: 'handlebars',
  template: Layout2template
},
  regions: {
  region1: '#contenttop',
  region2: '#contentbottom'
}

});

I want to add Layout2 in Layout1's region2. Or I want to nest layout inside layout. Any help would be appreciated.

Upvotes: 0

Views: 149

Answers (1)

ekeren
ekeren

Reputation: 3458

Layout extends directly from ItemView so creating nested layout is seamless in marionette.

inside onRender of Layout1, you should have this code:

onRender: function(){
  this.region2.show(new Layout2({
    ...//code here
  }));
}

Upvotes: 6

Related Questions