marionettejs/backbone.marionette — pull request #736 by lukaszfiszer (2013-10-08 14:48:14+00:00)
Title: Add "emptyClassName" option on Marionette.CollectionView

**Feature proposition**: Add "emptyClassName" option on Marionette.CollectionView, which adds a custom class to the `view.$el` when the collection is empty.

**Use case**: I have a CollectionView that displays a grid of photos. When there are no photos I display an `EmptyView` but I want it to be styled differently from a regular `ItemsView`. For example I want my `EmptyView` to take the whole width of the container, when a `ItemView` (=a photo in a grid) takes just 25%.

Because my `CollectionView` has `itemViewOptions.className` property set, both `ItemView` and `EmptyView` are rendered with the same class. This make different styling hard or impossible without some custom detecting whenever a collection is empty in our views. This is not DRY, because `Marionette.CollectionView` already does it.

Another, more generic solution to this problem is, as mentioned in #416, would be to use a `emptyViewOptions` property, but this would require much more changes to the codebase, as both `emptyView` and `itemView` are rendered now with the same `addItemView` method.

I'm open to comments and discussion. If this PR is would be accepted I will add missing unit tests and documentation update.