Skip to content

Instantly share code, notes, and snippets.

@thedeeno
Created November 15, 2011 22:33
Show Gist options
  • Save thedeeno/1368592 to your computer and use it in GitHub Desktop.
Save thedeeno/1368592 to your computer and use it in GitHub Desktop.
Spine: made to work by using a controller instead of model
class Bar extends Spine.Model
@configure "Bar"
class Foo extends Spine.Controller
constructor: ->
super
Bar.bind("create", @barCreated)
barCreated: (foo) =>
@trigger("update", this)
class FooController extends Spine.Controller
constructor: ->
super
@count = 0
@foo.bind("update", @render)
render: =>
@count += 1
console.log(@count)
# main
$(document).ready ->
# this correctly calls FooController#render once!
f = new Foo()
new FooController(foo: f)
new Bar().save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment