Last active
March 17, 2016 15:34
-
-
Save carloscabo/9144d3cc839a6ba852ac 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