From 95ef70a24ce060bd0018a847f1fec434a911fda7 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 22 Jul 2016 13:56:45 -0700 Subject: [PATCH] [API] Use selection state from toolbar (#1070) * [API] Allow selection * [API] Keep in sync using model * [API] Add selection as EventEmitter * [API] Use selection from ToDo tutorial * [API] Restore selection functionality --- tutorials/todo/todo.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tutorials/todo/todo.js b/tutorials/todo/todo.js index 5beebbc0d6..75a4bc5d46 100644 --- a/tutorials/todo/todo.js +++ b/tutorials/todo/todo.js @@ -58,8 +58,11 @@ define([ $(container).empty().append(self.$els); + self.initialize(); - self.objectChanged(object) + self.objectChanged(object); + + mct.selection.on('change', self.render); }); }; @@ -67,6 +70,7 @@ define([ if (this.mutableObject) { this.mutableObject.stopListening(); } + mct.selection.off('change', this.render); }; TodoView.prototype.setFilter = function (value) { @@ -78,8 +82,6 @@ define([ Object.keys(this.$buttons).forEach(function (k) { this.$buttons[k].on('click', this.setFilter.bind(this, k)); }, this); - - mct.selection.on('change', this.render); }; TodoView.prototype.render = function () { @@ -139,7 +141,6 @@ define([ function TodoToolbarView(domainObject) { this.domainObject = domainObject; this.mutableObject = undefined; - this.handleSelectionChange = this.handleSelectionChange.bind(this); }