Created
November 18, 2014 08:57
-
-
Save matijs/668de86fce95f2d71d04 to your computer and use it in GitHub Desktop.
jQuery-based enhancing of components / elements declared with a 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
$(function() { | |
'use strict'; | |
// kick off js enhancements | |
$('[data-enhancer]').each(function() { | |
var enhancer = this.getAttribute('data-enhancer'); | |
if (enhancers && typeof enhancers[enhancer] === 'function') { | |
enhancers[enhancer].call(this); | |
} | |
else { | |
if (window.console && typeof console.log === 'function') { | |
console.log('Non-existing decorator: "%s" on %o', decorator, this); | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment