Skip to content

Instantly share code, notes, and snippets.

@apt142
Last active August 29, 2015 14:04
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 apt142/c80398d70cbe5108b164 to your computer and use it in GitHub Desktop.
Save apt142/c80398d70cbe5108b164 to your computer and use it in GitHub Desktop.
Sandboxed JS Module
/* Js for /NAMESPACE/MODULE */
NAMESPACE = NAMESPACE || {};
NAMESPACE.MODULE = (function() {
var obj = {
// Context to operate in
context: '#side-well',
init: function ($el) {
this.$el = $el;
// Initialize stuff here
this.$('.btn').click(function () {
// Do something
window.console.log('click');
});
},
$: function (selector) {
return this.$el.find(selector);
},
additionalFunctions: function (data) {}
};
$(document).ready(function () {
var $el = $(obj.context);
if ($el.length) {
obj.init($el);
}
});
return obj;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment