Skip to content

Instantly share code, notes, and snippets.

@hanspagel
Last active February 11, 2016 15:29
Show Gist options
  • Save hanspagel/c7bcff3dc87f3d0a0d35 to your computer and use it in GitHub Desktop.
Save hanspagel/c7bcff3dc87f3d0a0d35 to your computer and use it in GitHub Desktop.
revealing module pattern with instances
/* ==========================================================================
Module
========================================================================== */
var Module = (function() {
var options = {
$this: false,
};
var init = function(customOptions) {
options = $.extend(options, customOptions);
if (!options.$this) return;
try {
_privateMethod();
} catch (error) {
console.log(error);
}
};
var _privateMethod = function() {
};
return {
init: init
};
})();
$(document).ready(function() {
$('[data-js="module"]').each(function() {
var options = $.parseJSON( $(this).attr('data-options') );
new Module().init({
$this: $(this),
options: options
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment