Skip to content

Instantly share code, notes, and snippets.

View aviflombaum's full-sized avatar

Avi Flombaum aviflombaum

View GitHub Profile
@aviflombaum
aviflombaum / gist:11442
Created September 18, 2008 16:25 — forked from sudara/gist:11441
delegate: function(rules) {
return function(e) {
var target = $(e.target), parent = null;
for (var selector in rules) {
if (target.is(selector) || ((parent = target.parents(selector)) && parent.length > 0)) {
return rules[selector].apply(this, [parent || target].concat($.makeArray(arguments)));
}
parent = null;
}
}