Skip to content

Instantly share code, notes, and snippets.

@erikakers
Last active December 21, 2015 03:19
Show Gist options
  • Save erikakers/6241813 to your computer and use it in GitHub Desktop.
Save erikakers/6241813 to your computer and use it in GitHub Desktop.
Javascript: Data Features Initialize
App.Features = {
init: function() {
var features = $('[data-features]'),
featuresArray = [],
$this = this;
if (!features.length) return false;
for (var i = 0, n = features.length; i < n; i++) {
var $element = $(features[i]),
func = $element.data('features');
featuresArray = func.split(' ');
_.forEach(featuresArray, function(func) {
if ($this[func] && typeof $this[func].init === 'function') {
$this[func].init($element);
}
});
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment