mercredi 14 septembre 2016

ember - How to correctly add bootstrap rows/cols based on number of records in model?

I have a route groups.index that showcases all the groups in my app. In the route I use the this.store.findAll('group'); to fetch all the groups and in the groups.index template I use the each to go through each group. I want to make it so that each group is contained within a bootstrap col-md-3 class, so that I can make 4 "panels" for each row showcasing the groups.

I made a helper class for handlebars that determines whether the index is at 0, or a multiple of 5, to determine where to start a row. I then use the same function to determine whether the index is a multiple of 4 to determine where to add the closing tag for a row. However I get a build error since I am not closing the divs within each block. Is there a way to make this work? Or is there a simpler way that I am missing?

groups.index template




<div class='row'>


<div class='col-md-3'>

</div>

 
</div>





helper function

export function isMultiple(params) {
  if (params[0] == 0) {
    return true;
  }
  const index = params[0] + 1;
  const multiple = params[1];
  return (index % multiple == 0);
}

export default Ember.Helper.helper(isMultiple);




Aucun commentaire:

Enregistrer un commentaire