Created
November 15, 2011 22:33
-
-
Save thedeeno/1368592 to your computer and use it in GitHub Desktop.
Spine: made to work by using a controller instead of model
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 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