Permalink
Browse files

Selecting all items individually will set the complete-all checkbox a…

…ppropriately.
  • Loading branch information...
1 parent 39c39e2 commit 7543a77aed2d6970ebd0f4c75bf1fbde5fa2fb29 @absoludity committed Aug 14, 2012
@@ -83,6 +83,12 @@ ready (model) ->
list.remove(i) for i in completed_indexes.reverse()
group.set('select_all', false)
+ exports.checkAllCompleted = ->
+ allCompleted = true
+ allCompleted &&= item.completed for item in list.get()
+ if allCompleted
+ group.set('select_all', true)
+
exports.endEdit = (e) ->
target = e.target
if target.tagName == "FORM"
@@ -36,7 +36,7 @@ <h1>todos</h1>
<todo:>
<li data-id={{id}} class="{#if .completed}completed{else}active{/}{#if ._editing} editing{/}">
<div>
- <input class="toggle" type="checkbox" checked={.completed}>
+ <input class="toggle" type="checkbox" checked={.completed} x-bind=change:checkAllCompleted>
<form x-bind=submit:endEdit>
<input class="text" x-bind="focus:startEdit, blur:endEdit" value="{.text}">
</form>

0 comments on commit 7543a77

Please sign in to comment.