Skip to content

Instantly share code, notes, and snippets.

@robdodson
Created August 4, 2012 06:41
Show Gist options
  • Select an option

  • Save robdodson/3255177 to your computer and use it in GitHub Desktop.

Select an option

Save robdodson/3255177 to your computer and use it in GitHub Desktop.
strategy
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