Skip to content

Instantly share code, notes, and snippets.

@sumitngupta
Created September 14, 2011 19:25
Show Gist options
  • Select an option

  • Save sumitngupta/1217521 to your computer and use it in GitHub Desktop.

Select an option

Save sumitngupta/1217521 to your computer and use it in GitHub Desktop.
Pipeline.Views.Watchlists = Backbone.View.extend({
el: '#watchlists-container',
initialize: function () {
_.bindAll(this, 'render');
this.collection.bind('add', this.addToList);
},
render: function () {
var container = $(this.el),
collection = this.options.collection;
collection.each(function (watchlist) {
var view = new Pipeline.Views.Watchlist({model: watchlist});
container.append(view.render().el);
});
return this;
},
addToList: function (watchlist) {
var watchlistView = new Pipeline.Views.Watchlist({model: watchlist});
console.log(watchlistView);
console.log("this", this);
console.log($(this.el));
$(this.el).append(watchlistView.render().el);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment