AmpersandJS / ampersand-collection-view

Renders a collection with one view per model within an element in a way that cleans up and unbinds all views when removed.
MIT License
12 stars 8 forks source link

Add support for optional `emptyView` #25

Closed samhashemi closed 9 years ago

samhashemi commented 9 years ago

This pull requests adds the ability to include an emptyView option, which is used when 0 views are rendered. It is automatically removed when the first collection item is added, and shown again when the collection goes back to zero.

The use case is showing a special view for empty lists, usually with instructions/graphics.

samhashemi commented 9 years ago

Note that one of the tests was modifying the ItemView prototype, and screwing up subsequent tests. I cleaned that up as well.

latentflip commented 9 years ago

+1 haven't checked out the code, but took a read and this looks good to me, and CI builds pass. Thanks @samhashemi!

aaronmccall commented 9 years ago

+1

layflags commented 9 years ago

Exactly what I need. Would currently save me some lines of code. Thanks @samhashemi! Please add this enhancement soon guys!

samhashemi commented 9 years ago

Any chance we can get this merged? cc @latentflip

latentflip commented 9 years ago

@samhashemi sure, though, just realised we'll need to get it documented too. Maybe over in https://github.com/AmpersandJS/ampersand-view#rendercollection-viewrendercollectioncollection-itemview-containerel-viewoptions somewhere. Think you can do that too?