Skip to content

Commit

Permalink
🐛 It's toggle not complete. #CallAThingAThing /cc @tmornini
Browse files Browse the repository at this point in the history
  • Loading branch information
snuggs committed Jul 7, 2017
1 parent f8179c5 commit b1ad6f0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
25 changes: 19 additions & 6 deletions examples/to-do/index.es
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,32 @@ Element `to-do`

initialize () {
this.context.tasks =
[{ task: 'Wash clothes' }, { task: 'Eat food' }]
[{ task: 'Wash clothes', completed: true }, { task: 'Eat food' }]
}

onsubmit (event, input = this.select `input`) {
event.preventDefault ()

this.context.tasks
.push (input.value)
.push ({ task: input.value })

input.value = ''
}

onidle () { console.log ('idling') }
onidle () {
const
check = (task, id) =>
task.completed && mark (id)

, mark = (id, selector = `input[id="${id}"]`) =>
this
.select (selector)
.checked = true

this.tasks.map (check)

console.log ('idling')
}

all (event) {
event.prevent () // from painting
Expand All @@ -26,9 +39,9 @@ Element `to-do`
.map (checkbox => checkbox.checked = true)
}

complete (event, id = event.target.id) {
this.context.tasks
[id].completed = true
toggle (event, id = event.target.id) {
this.context.tasks[id].completed =
!!!this.context.tasks[id].completed
}

remove (event) {
Expand Down
2 changes: 1 addition & 1 deletion examples/to-do/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h1>{name}'s &lt;to-do&gt; List</h1>
<template name=tasks>
<fieldset>
<!-- {#} - current index -->
<input id={#} onclick=complete type=checkbox>
<input id={#} onclick=toggle type=checkbox>

<label for={#}>{task}</label>

Expand Down

0 comments on commit b1ad6f0

Please sign in to comment.