Created
May 18, 2012 11:00
-
-
Save flashingpumpkin/2724680 to your computer and use it in GitHub Desktop.
Cuffs.js Todo App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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