mardi 25 octobre 2016

Emberjs - looping through an array 'each', but performing a different action every three objects

When using bootstrap + emberjs, I want to create a new <div class="row"> for every three objects in an array.

This is how I solved the same problem using Ruby+Rails.

<% @movies.in_groups_of(3) do |group| %>
    <div class="row">
    <% group.each do |movie| %>
         <div class="col-md-4">
             <h3><%= movie.title</h3>
             <%= image_tag(movie.thumb_url) %>
         </div>
     <% end %>
     </div>
<% end %>

I'm not sure (and am looking for help) on what "the ember way" of dealing with this is, obviously the below code results in a new row each time this loop completes - which is not the desired outcome.


  <div class="row">
    <div class="col-md-4">
      <h3></h3>
      <strong>Category Name</strong>
      <img width="100%" src="" alt="" />
    </div>
  </div>


Assistance greatly appreciated - thanks!




Aucun commentaire:

Enregistrer un commentaire