Created
February 12, 2009 17:16
-
-
Save tooky/62742 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#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