Skip to content

Instantly share code, notes, and snippets.

@brettjonesdev
Last active May 2, 2017 01:32
Show Gist options
  • Save brettjonesdev/812fe02a455d08e9e4a4c62821cccabc to your computer and use it in GitHub Desktop.
Save brettjonesdev/812fe02a455d08e9e4a4c62821cccabc to your computer and use it in GitHub Desktop.
const App = new Application();
App.selectedTodos = new Backbone.Collection();
// List Route
const collection = new TodoCollection();
collection.fetch().then(() => {
const listView = new ListView({
collection,
selectedTodos: App.selectedTodos
}).render();
});
// ListView
const ListView = Backbone.View.extend({
initialize(options) {
this.selectedTodos = options.selectedTodos
},
select(model) {
this.selectedTodos.add(model);
},
unselect(model) {
this.selectedTodos.remove(model);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment