Skip to content

Commit

Permalink
Merge pull request #1504 from trek/documentation-about-collectionview…
Browse files Browse the repository at this point in the history
…-childview-creation

Documents programatic creation of child views for CollectionView
  • Loading branch information
wagenet committed Nov 2, 2012
2 parents bf77281 + e0ced29 commit 6e343cc
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions packages/ember-views/lib/views/collection_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,24 @@ var get = Ember.get, set = Ember.set, fmt = Ember.String.fmt;
``` javascript
Ember.CollectionView.CONTAINER_MAP['article'] = 'section'
```
## Programatic creation of child views
For cases where additional customization beyond the use of a single `itemViewClass`
or `tagName` matching is required CollectionView's `createChildView` method can be
overidden:
``` javascript
CustomCollectionView = Ember.CollectionView.extend({
createChildView: function(viewClass, attrs) {
if (attrs.content.kind == 'album') {
viewClass = App.AlbumView;
} else {
viewClass = App.SongView;
}
this._super(viewClass, attrs);
}
});
```
## Empty View
You can provide an `Ember.View` subclass to the `Ember.CollectionView` instance as its
`emptyView` property. If the `content` property of a `CollectionView` is set to `null`
Expand Down

0 comments on commit 6e343cc

Please sign in to comment.