Created
          May 27, 2015 11:53 
        
      - 
      
 - 
        
Save joshforbes/fe10404b300b4b90eacd 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
    
  
  
    
  | var counter = { | |
| count: 0, | |
| init: function() { | |
| this.$count = $('#count'); | |
| this.setCount(parseInt(this.$count.text(), 10)); | |
| this.bindEvents(); | |
| }, | |
| bindEvents: function() { | |
| $('#add').on('click', $.proxy(this.add, this)); | |
| $('#subtract').on('click', $.proxy(this.subtract, this)); | |
| }, | |
| add: function() { | |
| this.setCount(this.count + 1); | |
| }, | |
| subtract: function() { | |
| this.setCount(this.count - 1); | |
| }, | |
| setCount: function(val) { | |
| this.count = val; | |
| this.render(); | |
| }, | |
| render: function() { | |
| this.$count.text(this.count); | |
| } | |
| }; | |
| counter.init(); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment