Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are a number of different ways you could make this work, as you've already discovered. Each of the options will be better suited to a specific set of circumstances, but it's also possible that your circumstances are such that there isn't a "best" way to accomplish what you want. If that's the case, just pick one and move on. :)</p> <h3>Map The Tags To A Single Value</h3> <p>This is what you've suggested already. It would work well in situations where the number of tags is relatively small and you don't need any custom actions taken when someone clicks on a specific tag. For example, if you're just setting up each tag as an <code>&lt;a href="#{tag-name}"&gt;</code> link, you could easily do this with the tags mapped down to a simple array.</p> <h3>Iterate The Tag Collection In The Template</h3> <p>Basically the same as the mapping option, except instead of reducing the tags down to a simple array of strings, you would iterate the tag collection in the template as models, and call model.get(...) in order to get the data you need.</p> <p>If you're using a template engine like Handlebars, this becomes really easy to do and might produce a much more clean result through the use of sub-templates.</p> <p>I probably wouldn't recommend this approach for underscore templates, though, as they tend to get muddy and ugly fast, when doing iteration.</p> <h3>A CollectionView Of CllectionViews, Using A Layout</h3> <p>This is the more complex option but also the most capable.</p> <p>Configure the <code>itemView</code> for the collection of books as a layout. The layout would have a single region in it, and the region would be populated with another collectionview to render each of the individual tags.</p> <p>The benefit here is that you can have a lot more code and functionality associated with your individual tag that is being rendered. You'll have a single view instance for each tag, which means it will be easier to keep that code encapsulated and organized.</p> <p>The drawback is that you'll have a view instance for every tag, and more code to write just to get this set up and running.</p> <h3>CollectionView of CompositeViews</h3> <p>The compositeview lets you render a wrapper template around the collection, which may prove to be an advantage over CollectionView.</p> <p>You would need a CollectionView, still. This CollectionView would render a CompositeView as it's <code>itemView</code>. The CompositeView would specify an <code>itemViewContainer</code> to render the collection of tags. Each tag gets it's own view instance, still.</p> <p>You could get rid of the Layout and region this way. The visual result is the same as using a CollectionView with Layouts, but the amount of code to do it is probably reduced significantly. </p> <hr> <p>Personally, I would either do the map/reduce to get the tags down to a simple array, or use a CollectionView Of CompositeViews.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload