Skip to content

Instantly share code, notes, and snippets.

@quirkey
Created February 24, 2009 22:35
Show Gist options
  • Select an option

  • Save quirkey/69840 to your computer and use it in GitHub Desktop.

Select an option

Save quirkey/69840 to your computer and use it in GitHub Desktop.
// works like Prototype's Function#bind
// in Prototype:
// $('element').observe('click', this.clickMethod.bind(this));
// with jQuery + $.shove:
// $('#element).click($.shove(this.clickMethod, this));
$.extend({
shove: function(fn, object) {
return function() {
return fn.apply(object, arguments);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment