Skip to content Skip to sidebar Skip to footer

Render Multiple View/controller Pairs

I am currently rendering a list of views:
    {{#each newsItem in controller}} {{view App.NewsItemView contentBinding='newsItem' class='news-item' }} {{/each

Solution 1:

{{render}} should be fixed in current master (if you build it from Github). You should be able to use it multiple times if you pass a model:

<ul>
 {{#each controller}}
   {{render "newsItem" this}}
 {{/each}}
</ul>

{{control}} is still there but hidden behind a flag (because it's still experimental). To use it you need to do : ENV.EXPERIMENTAL_CONTROL_HELPER = true before including the ember.js file. If you can avoid using it, it would be better.

However I think the simplest approach would be to use itemController:

<ul>
  {{#each controller itemController="newsItem"}}
    {{view App.NewsItemView class="news-item" }}
  {{/each}}
</ul>

I think you can combine them to make it simpler (I haven't tried it yet):

<ul>
  {{each controller itemController="newsItem" itemViewClass="App.NewsItemView"}}
</ul>

Post a Comment for "Render Multiple View/controller Pairs"