Last active
February 11, 2016 15:29
-
-
Save hanspagel/c7bcff3dc87f3d0a0d35 to your computer and use it in GitHub Desktop.
revealing module pattern with instances
This file contains hidden or 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
/* ========================================================================== | |
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