Created
September 25, 2012 15:20
-
-
Save zhannes/3782561 to your computer and use it in GitHub Desktop.
create objs with constructors
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 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