Skip to content

Instantly share code, notes, and snippets.

@flashingpumpkin
Created May 18, 2012 11:00
Show Gist options
  • Save flashingpumpkin/2724680 to your computer and use it in GitHub Desktop.
Save flashingpumpkin/2724680 to your computer and use it in GitHub Desktop.
Cuffs.js Todo App
class TodoController
constructor: ({@context})->
@todos = []
@context.set 'todos': todos
@context.addTodo = ()=>
@todos.push text: @context.get('todo'), done: false
@context.set 'todos', @todos
@context.markDone = (todo)=>
todo.done = true
<!DOCTYPE html>
<html>
<head>
<title>Cuffs Do</title>
</head>
<body data-app data-controller="TodoController">
<input type="text" data-bind="todo" data-change="addTodo" />
<ul>
<li data-loop="todo in todos" data-show="todo.done==false">
<span data-bind="todo.text"></span>
<button data-click="markDone:todo">Done</button>
</li>
</ul>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment