-
-
Save enoliglesias/c3964c351a6ee0f824e1 to your computer and use it in GitHub Desktop.
JS Module with closure
This file contains 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
;(function($, undefined) { | |
'use strict'; | |
if (typeof window.MY_MODULE_NAME !== 'undefined') { | |
return; | |
} | |
// | |
// Module general vars | |
// | |
var | |
$document = $(document), | |
data = {}; | |
// | |
// Methods | |
// | |
function init(params) { | |
// Method code here | |
} | |
function anotherMethod(params) { | |
// Method code here | |
} | |
// | |
// Modeule events | |
// | |
$document.on('change', 'SELECTOR', function(){ | |
}) | |
.on('click', 'SELECTOR', function(){ | |
}); | |
// | |
// Public methods / properties | |
// | |
window.MY_MODULE_NAME = { | |
init: init, | |
data: data | |
}; | |
}(jQuery)); | |
// Usage | |
// MY_MODULE_NAME.init(params); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment