Created
January 25, 2014 02:56
-
-
Save brendanfalkowski/8611120 to your computer and use it in GitHub Desktop.
Get "data-callback" attribute from markup, check if the function exists, and then call it.
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
var elem = $('.selector'); | |
elem.on('click', function (e) { | |
var callbackName = $(this).data('callback'); | |
if ($.isFunction(window[callbackName])) { | |
window[callbackName].call(this); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment