trabian/trabian-webapp-core — pull request #10 by trabianmatt (2013-10-18 12:42:34+00:00)
Title: Add `hideIfEmpty` option to BaseCollectionView

This will toggle the visibility of the view based on whether the collection is
empty.

A couple of notes:

* The visibility is not dependent on the sync status of the collection,
so if the collection is empty because it hasn't been fetched then the
view will still be hidden. If you'd like to show a "Loading" or
"Empty" fallback then don't use this option.

* We use a Presenter with an `empty` attribute. This way we only toggle
the visibility when the value of `empty` changes. A potentially
more straightforward approach would be to use something like:

`@$el.toggle ! @collection.isEmpty()`

However we introduced the presenter under the admittedly intution-
driven assumption that the jQuery code for determining whether to
toggle the element (which requires determing the current visibility)
is heavier than the Backbone.Model approach of checking the existing
value of a hash attribute.