walmartlabs / thorax

Strengthening your Backbone
http://thoraxjs.org/
Other
1.32k stars 129 forks source link

CollectionView: Support for header and footer #402

Open MichaReiser opened 9 years ago

MichaReiser commented 9 years ago

If the collection helper is used to render e.g. an ul, then it's hard to add a header and footer (need to use appendItem). It would be nice if this common case would be possible from the handlebars template.

{{#collection ... tagName="ul"}}
    <li class="header">...</li>
    {{collection-element}}
    <li class="footer">..</li>
{{/collection}}

Instead of inserting a new Wrapper-Element in the collection-element helper, it should append it to the parents element (maybe another helper name should be used).

This change would require to rewrite the update mechanism in the CollectionView (which first removes all content from the collection.el and then renders the items.

jasonwebster commented 9 years ago

In the mean time, it's possible to achieve this by subclassing CollectionView and using that (including {{collection-element}} and your other content in its template, instead of using the {{collection}} helper.