Skip to content

Instantly share code, notes, and snippets.

@christoomey
Created May 11, 2011 00:23
Show Gist options
  • Save christoomey/965669 to your computer and use it in GitHub Desktop.
Save christoomey/965669 to your computer and use it in GitHub Desktop.
Javascript object literal code organization pattern
// Object literal code organization pattern. From Rebecca Murphy's blog:
// http://blog.rebeccamurphey.com/2009/10/15/using-objects-to-organize-your-code
var myModule = {
'config' : {
'option1' = val,
'cached_elem' = $(this)
},
'init' : function(config) {
// provide for custom configuration via init()
if (config && typeof(config) == 'object') {
$.extend(myModule.config, config);
}
}
'methodOne' : function() { },
'methodTwo' : function() { },
};
$(document).ready(myFeature.init);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment