Created
May 31, 2013 11:42
-
-
Save jsdbroughton/5684446 to your computer and use it in GitHub Desktop.
jQuery var function to pass into a $(query).each() loop. In the stripped instance here, HTML5 data-* tags can control multiple events and types within one each call. "desk" here is a constructor with prototyped functions, but really the typeof test could be replaced with an eval on the value in the data-* attribute.
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
iconFunctions = function() { | |
$(this).click(function (e) { | |
var f = (e.target.attributes['data-function'] || {}).textContent; | |
if (typeof desk[f] === 'function') { | |
desk[f](e); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment