Created
October 16, 2012 06:28
-
-
Save natew/3897528 to your computer and use it in GitHub Desktop.
jQuery function to mass bind events based on a parent
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
$.fn.allOn = function(onEvent, bindings) { | |
for (var target in bindings) { | |
(function(t) { | |
$(this).on(onEvent, t, function(e) { | |
bindings[t].call(this, e, $(this)); | |
}); | |
})(target); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example usage: