Created
August 4, 2012 06:41
-
-
Save robdodson/3255177 to your computer and use it in GitHub Desktop.
strategy
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 Button = function(id) { | |
| this.id = id; | |
| this.$context = $(id); | |
| this.$context.on('click', $.proxy(this.handleClick, this)); | |
| } | |
| Button.prototype.changeAction = function(action) { | |
| this.action = action; | |
| } | |
| Button.prototype.handleClick = function() { | |
| this.action(); | |
| } | |
| var btn = new Button('#button-expand'); | |
| btn.changeAction(function() { | |
| console.log('logging in!'); | |
| btn.changeAction(function() { | |
| console.log('hitting facebook'); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment