Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleanup to-do example

  • Loading branch information...
commit 9cd2f5c2bd1f63a45ad88f7cbc67f826de4950a8 1 parent ae1fbcb
@pyykkis pyykkis authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 examples/todo-app/index.html
View
12 examples/todo-app/index.html
@@ -14,9 +14,12 @@
<input type="text" name="task" />
<input type="submit" value="Add" />
</form>
- <div id="tasks">
- <div><input type="checkbox"/><span class="task"></span></div>
- </div>
+ <table id="tasks">
+ <tr>
+ <td class="task"></td>
+ <td><a class="delete" href="#">delete</a></td>
+ </tr>
+ </table>
<script type="text/coffeescript">
data = [{task: "Foo"}, {task: "Bar"}]
@@ -28,13 +31,14 @@
tasks.on 'update', ->
tasks.render data
+
$('#add-task').submit (event) ->
event.preventDefault()
data.push task: input.val()
input.val ""
tasks.trigger 'update'
- tasks.on 'click', 'input[type="checkbox"]', (event) ->
+ tasks.on 'click', '.delete', (event) ->
taskName = event.target.transparency.model.task
data = _.reject(data, (e) -> e.task == taskName)
tasks.trigger 'update'
Please sign in to comment.
Something went wrong with that request. Please try again.