Skip to content

Instantly share code, notes, and snippets.

@matijs
Created November 18, 2014 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save matijs/668de86fce95f2d71d04 to your computer and use it in GitHub Desktop.
Save matijs/668de86fce95f2d71d04 to your computer and use it in GitHub Desktop.
jQuery-based enhancing of components / elements declared with a data-attribute
$(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