Created
September 23, 2012 22:27
-
-
Save tdreyno/3773259 to your computer and use it in GitHub Desktop.
An Ember.js Collection view which has childViews depending on a property of the data row.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FS.MultiplexingCollectionView = Em.CollectionView.extend({ | |
itemViewClass: Em.View, | |
typeProperty: "type", | |
viewMap: {}, | |
createChildView: function(view, attrs) { | |
var map = this.get("viewMap"); | |
var prop = this.get("typeProperty"); | |
if (attrs.content[prop] && (klassName = map[attrs.content[prop]])) { | |
view = Ember.getPath(klassName); | |
} | |
return this._super(view, attrs) | |
} | |
}); | |
FS.SlidesCollectionView = FS.MultiplexingCollectionView.extend({ | |
typeProperty: "type", | |
viewMap: { | |
interstitial: "FS.InterstitialView", | |
grid: "FS.GridView", | |
leader_board: "FS.LeaderboardSlideView" | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment