Skip to content

Instantly share code, notes, and snippets.

@adamjleonard
Created October 24, 2011 13:47
Show Gist options
  • Save adamjleonard/1309064 to your computer and use it in GitHub Desktop.
Save adamjleonard/1309064 to your computer and use it in GitHub Desktop.
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