Skip to content

Instantly share code, notes, and snippets.

@raine
Last active December 17, 2015 14:59
Show Gist options
  • Select an option

  • Save raine/5628124 to your computer and use it in GitHub Desktop.

Select an option

Save raine/5628124 to your computer and use it in GitHub Desktop.
app.SettingsView = Marionette.ItemView.extend({
// ...
initialize: function() {
this.whitelist = new app.TopicsWhitelist();
},
ui: {
'topics': '#topics .checkboxes'
},
onRender: function() {
var topics = this.whitelist.render().el;
this.ui.topics.html(topics);
}
});
app.TopicsWhitelist = Backbone.View.extend({
tagName: 'ul',
initialize: function() {
this.topics = new app.Topics();
this.listenTo(this.topics, 'reset', this.reset);
this.fetch();
},
reset: function() {
app.Options.vent.trigger('topics:ready');
},
render: function() {
this.$el.append(this.topics.map(function(topic) {
return new app.TopicView({ model: topic }).render().el;
}));
return this;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment