Commit 2d8b292f authored by Sam Saccone's avatar Sam Saccone

correctly update list according to filter state.

Fixes #1290
parent aa118065
...@@ -99,7 +99,8 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette) { ...@@ -99,7 +99,8 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette) {
}, },
collectionEvents: { collectionEvents: {
'all': 'update' 'change:completed': 'render',
all: 'setCheckAllState'
}, },
initialize: function () { initialize: function () {
...@@ -111,17 +112,12 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette) { ...@@ -111,17 +112,12 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette) {
return child.matchesFilter(filteredOn); return child.matchesFilter(filteredOn);
}, },
onRender: function () { setCheckAllState: function () {
this.update();
},
update: function () {
function reduceCompleted(left, right) { function reduceCompleted(left, right) {
return left && right.get('completed'); return left && right.get('completed');
} }
var allCompleted = this.collection.reduce(reduceCompleted, true); var allCompleted = this.collection.reduce(reduceCompleted, true);
this.ui.toggle.prop('checked', allCompleted); this.ui.toggle.prop('checked', allCompleted);
this.$el.parent().toggle(!!this.collection.length); this.$el.parent().toggle(!!this.collection.length);
}, },
......
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