Created
June 27, 2011 21:31
-
-
Save colwilson/1049890 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 window.CounterView extends Backbone.View | |
initialize: -> | |
@counter = new Counter() | |
@counter.bind('change', @render) | |
el: $('#counter') | |
events: | |
'click button#inc-count' : 'inc' | |
'click button#dec-count' : 'dec' | |
render: => | |
$(@el).find("#count").html "The count is " \ | |
+ @counter.get("count") | |
@ | |
inc: -> | |
ct = @counter.get("count") | |
@counter.set(count: ct+1) | |
dec: -> | |
ct = @counter.get("count") | |
@counter.set(count: ct-1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment