From dccfdac94635f306bb5c788b77605d11ee1fa43a Mon Sep 17 00:00:00 2001 From: callmephilip Date: Wed, 1 May 2013 10:44:08 -0700 Subject: [PATCH] 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 --- .../backbone_marionette/js/TodoMVC.Layout.js | 5 ++++- .../backbone_marionette/js/TodoMVC.TodoList.Views.js | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/labs/architecture-examples/backbone_marionette/js/TodoMVC.Layout.js b/labs/architecture-examples/backbone_marionette/js/TodoMVC.Layout.js index eb89e8c9d1..f76cb19860 100644 --- a/labs/architecture-examples/backbone_marionette/js/TodoMVC.Layout.js +++ b/labs/architecture-examples/backbone_marionette/js/TodoMVC.Layout.js @@ -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 () { diff --git a/labs/architecture-examples/backbone_marionette/js/TodoMVC.TodoList.Views.js b/labs/architecture-examples/backbone_marionette/js/TodoMVC.TodoList.Views.js index d76cec61a5..ded1c0878c 100644 --- a/labs/architecture-examples/backbone_marionette/js/TodoMVC.TodoList.Views.js +++ b/labs/architecture-examples/backbone_marionette/js/TodoMVC.TodoList.Views.js @@ -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 () {