Skip to content

Instantly share code, notes, and snippets.

@wolffc
Created May 22, 2013 20:05
Show Gist options
  • Save wolffc/5630476 to your computer and use it in GitHub Desktop.
Save wolffc/5630476 to your computer and use it in GitHub Desktop.
jQuery: Module Pattern Template
// jQuery Module Pattern
(function($) {
// The jQuery function
$.MyModuleName = function(options) {
var mod = {
options: $.extend(
// Default Options
{
'optionaName1': 'defaultValue',
'optionaName2': 'defaultValue2',
}, options),
// Private functions
privFunction: function( ) {
// call obect function via this
this.privFunction2( );
},
privFunction2: function( ) {
},
};
// Pulic Api Exposed
return {
publicFunctionName: mod.privFunction,
publicFunctionName2: mod.privFunction2,
};
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment