Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Appending another view within a region - marionette

I was using Backbone LayoutManager for managing my views within the app. I wanted to try marionette. I came across a issue where i couldn't append a view to a region.

HTML

<body>
  <div id="content">
       <header id="header"></header>
       <div id="wrapper">
               <span>Some View Content</span>
       </div>
       <footer id="footer"></footer>
  </div>
</body>  

App.js

MyApp = new Backbone.Marionette.Application();
var rm = new Marionette.RegionManager();

var regions = rm.addRegions({
    mainRegion : '#content',
    headerRegion : '#header',
    wrapperRegion : '#wrapper',
    footerRegion : '#footer'
});

regions.headerRegion.show(new HeaderView());
regions.wrapperRegion.show(new SomeView());
regions.footerRegion.show(new FooterView());

If i want to append another view in wrapperRegion how can do this ?

I also wanted to know is there a way to insert another view into my existing view? Layout Manager allowed me to do write below mentioned code.. How can i achieve something like this in marionette ?

var MyView = Backbone.View.extend({

  tagName: "div",

  beforeRender: function() {
     this.insertView(new ItemView());
  }
});
like image 851
user1184100 Avatar asked May 19 '13 10:05

user1184100


1 Answers

One view per region. Just define another region to put your other view in.

like image 110
Robert Levy Avatar answered Oct 14 '22 06:10

Robert Levy