Permalink
Browse files

Merge pull request #545 from thebakeryio/feature/backbone-marionette-…

…model-shortcuts

use Marionette's event hashes for Model and Collection events
  • Loading branch information...
sindresorhus committed May 5, 2013
2 parents 37174a6 + dccfdac commit 41ef0d4a60ac8c92414c11fba390d96fae6c293e
@@ -48,9 +48,12 @@ TodoMVC.module('Layout', function (Layout, App, Backbone) {
'click #clear-completed': 'onClearClick'
},
+ collectionEvents: {
+ 'all': 'updateCount'
+ },
+
initialize: function () {
this.listenTo(App.vent, 'todoList:filter', this.updateFilterSelection, this);
- this.listenTo(this.collection, 'all', this.updateCount, this);
},
onRender: function () {
@@ -23,8 +23,8 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette, $)
'click .toggle': 'toggle'
},
- initialize: function () {
- this.listenTo(this.model, 'change', this.render, this);
+ modelEvents: {
+ 'change': 'render'
},
onRender: function () {
@@ -93,8 +93,8 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette, $)
'click #toggle-all': 'onToggleAllClick'
},
- initialize: function () {
- this.listenTo(this.collection, 'all', this.update, this);
+ collectionEvents: {
+ 'all' : 'update'
},
onRender: function () {

0 comments on commit 41ef0d4

Please sign in to comment.