Skip to content

Instantly share code, notes, and snippets.

@zhannes
Created September 25, 2012 15:20
Show Gist options
  • Save zhannes/3782561 to your computer and use it in GitHub Desktop.
Save zhannes/3782561 to your computer and use it in GitHub Desktop.
create objs with constructors
function Foo(el, options){
if(!el) throw new Error("'el' is a required param");
this.$el = el.jquery ? el : $(el);
this.options = options || {};
}
Foo.prototype = {
messageStart: "Phuket, ",
getContent: function(){
var messaage = this.messageStart + this.options.content;
return message;
},
render: function(){
this.$el.append( this.getContent() );
}
}
var $el = $('#your_container'),
options = { content: "I'll get the sea breeze"},
foo = new Foo( $el, options );
foo.render();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment