Created
October 24, 2011 13:47
-
-
Save adamjleonard/1309064 to your computer and use it in GitHub Desktop.
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 TaskApp extends Spine.Controller | |
# Add event listeners | |
events: | |
"submit form": "create" | |
"click .clear": "clear" | |
# Create some local variables refering to elements | |
elements: | |
".items": "items" | |
"form input": "input" | |
constructor: -> | |
super | |
Task.bind("create", @addOne) | |
Task.bind("refresh", @addAll) | |
Task.fetch() | |
addOne: (task) => | |
view = new Tasks(item: task) | |
@items.append(view.render().el) | |
addAll: => | |
Task.each(@addOne) | |
create: (e) -> | |
e.preventDefault() | |
Task.create(name: @input.val()) | |
@input.val("") | |
clear: -> | |
Task.destroyDone() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment