Skip to content

Instantly share code, notes, and snippets.

@jondavidjohn
Created July 10, 2011 04:46
Show Gist options
  • Save jondavidjohn/1074281 to your computer and use it in GitHub Desktop.
Save jondavidjohn/1074281 to your computer and use it in GitHub Desktop.
Javascript Component Starting point
var component = (function($){
var default_options = {
array_option : [],
string_option : "default"
};
return {
other_function: function(args) {
//store context
var self = this;
},
init: function(options) {
var self = this;
self.o = $.extend(default_options, options);
/***
* Initialize component
*/
self.other_function(args);
}
};
})(jQuery);
<script src="jquery.js"></script>
<script src="component.js"></script>
<script type="text/javascript">
component.init({
array_option : ["1","2"],
string_option : "This is a string being put into my component"
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment