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) { ...@@ -48,9 +48,12 @@ TodoMVC.module('Layout', function (Layout, App, Backbone) {
'click #clear-completed': 'onClearClick' 'click #clear-completed': 'onClearClick'
}, },
collectionEvents: {
'all': 'updateCount'
},
initialize: function () { initialize: function () {
this.listenTo(App.vent, 'todoList:filter', this.updateFilterSelection, this); this.listenTo(App.vent, 'todoList:filter', this.updateFilterSelection, this);
this.listenTo(this.collection, 'all', this.updateCount, this);
}, },
onRender: function () { onRender: function () {
......
...@@ -23,8 +23,8 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette, $) ...@@ -23,8 +23,8 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette, $)
'click .toggle': 'toggle' 'click .toggle': 'toggle'
}, },
initialize: function () { modelEvents: {
this.listenTo(this.model, 'change', this.render, this); 'change': 'render'
}, },
onRender: function () { onRender: function () {
...@@ -93,8 +93,8 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette, $) ...@@ -93,8 +93,8 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette, $)
'click #toggle-all': 'onToggleAllClick' 'click #toggle-all': 'onToggleAllClick'
}, },
initialize: function () { collectionEvents: {
this.listenTo(this.collection, 'all', this.update, this); 'all' : 'update'
}, },
onRender: function () { 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