Commit dccfdac9 authored by callmephilip's avatar callmephilip

use Marionette's event hashes for Model and Collection events

refer to Marionette's documentation for more details https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.view.md#viewmodelevents-and-viewcollectionevents
parent 8ea9aef8
......@@ -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 () {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment