Skip to content

Instantly share code, notes, and snippets.

@nickstenning
Created September 8, 2009 22:42
Show Gist options
  • Select an option

  • Save nickstenning/183287 to your computer and use it in GitHub Desktop.

Select an option

Save nickstenning/183287 to your computer and use it in GitHub Desktop.
addDelegatedEvent: function (selectorOrElement, event, functionName) {
var __obj = this;
$(this.element).bind(event, function (ev) {
for(var el = ev.target; el !== __obj.element.parentNode; el = el.parentNode) {
if (el === selectorOrElement || $(el).is(selectorOrElement)) {
return __obj[functionName].apply(__obj, arguments);
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment