Skip to content

Instantly share code, notes, and snippets.

@brendanjerwin
Created July 6, 2012 16:03
Show Gist options
  • Select an option

  • Save brendanjerwin/3061074 to your computer and use it in GitHub Desktop.

Select an option

Save brendanjerwin/3061074 to your computer and use it in GitHub Desktop.
renderSubViews: function(options){
var el = options.el;
var items = options.items;
if(!el){throw Error('renderSubViews must be provided an el option to render into.');}
if(!items){throw Error('renderSubViews must be provided and items option containing the models to render.');}
if(!this.subView){throw Error('cannot call renderSubView without the view implementing the subView key.'); }
var i,j;
this._glee_items_el = el;
for(i=0,j=items.length;i<j;i++){
this.addSubView(items[i], options);
}
},
addSubView: function(item, extraOI){
if(!this._glee_items_el){throw Error('cannot call addSubView before renderSubViews.'); }
this._glee_items.push(this._SubView.render(_.extend({model:item, el: this._glee_items_el}, this.oi, extraOI)));
},
getSubViews: function() {
return this._glee_items;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment