Skip to content

Instantly share code, notes, and snippets.

@tooky
Created February 12, 2009 17:16
Show Gist options
  • Save tooky/62742 to your computer and use it in GitHub Desktop.
Save tooky/62742 to your computer and use it in GitHub Desktop.
jQuery.fn.delegate = function(eventType, rules) {
return this.bind(eventType, function(e) {
var target = $(e.target);
for(var selector in rules)
if(target.is(selector))
return rules[selector].apply(this, arguments)
})
}
$("#thing").delegate("click", {
".quit": function() { /* do quit stuff */ },
".edit": function() { /* do edit stuff */ }
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment