From 6373796e3fde95df18659e59f742540dddeae295 Mon Sep 17 00:00:00 2001 From: Michael Nelson Date: Tue, 14 Aug 2012 22:08:47 +0200 Subject: [PATCH] SelectAll should also uncheck when individual items are unchecked (the things you remember while trying to sleep). --- labs/architecture-examples/derbyjs/src/todos/index.coffee | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/labs/architecture-examples/derbyjs/src/todos/index.coffee b/labs/architecture-examples/derbyjs/src/todos/index.coffee index 473732a5cf..f21794705f 100644 --- a/labs/architecture-examples/derbyjs/src/todos/index.coffee +++ b/labs/architecture-examples/derbyjs/src/todos/index.coffee @@ -55,6 +55,10 @@ ready (model) -> group = model.at '_group' group.on 'set', 'select_all', (select_all, previous_value, isLocal, e) -> + # We only want to react to select_all being set if it's in response + # to a UI event (as opposed to our checkAllCompleted below checking + # individual items). + return unless e # Is there a way to do this with one call rather than iterating? todos = model.at('_group.todos') for item in list.get() @@ -87,8 +91,7 @@ ready (model) -> exports.checkAllCompleted = -> allCompleted = true allCompleted &&= item.completed for item in list.get() - if allCompleted - group.set('select_all', true) + group.set('select_all', allCompleted) exports.endEdit = (e) -> target = e.target