Skip to content

Instantly share code, notes, and snippets.

@Artforge
Forked from tabouassaleh/layout.onrender.js
Created December 1, 2013 23:04
Show Gist options
  • Save Artforge/7742059 to your computer and use it in GitHub Desktop.
Save Artforge/7742059 to your computer and use it in GitHub Desktop.
onRender: function() {
var filter = this.options.filter || this.filter;
var view= new ListView({collection: TitanFile.channelList, filter: filter});
var contentPromise = this.content.show(view);
return contentPromise;
}
Backbone.Marionette.CollectionView.prototype.addChildView = function(item, collection, options) {
var filter = this.options.filter || this.filter;
if (filter && !filter(item)) return;
this.closeEmptyView();
var ItemView = this.getItemView();
return this.addItemView(item, ItemView, options.index);
};
Backbone.Marionette.CollectionView.prototype.showCollection = function() {
var filter = this.options.filter || this.filter;
var that = this;
var ItemView = this.getItemView();
this.collection.each(function(item, index){
if (filter && ! filter(item)) return;
that.addItemView(item, ItemView, index);
});
};
var StarredListLayout = ListLayout.extend({
filter: function(item) { return item.get('is_starred'); },
templateHelpers: {pageTitle: 'Starred List'}
});
var StarredListView = ListView.extend({
filter: function(item) { return item.get('is_starred'); },
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment