i've searched on google, and read many articles about js pattern, n get confused. I search on stackoverflow, and still confused. So, i think, i have to ask here. (Im still newbie in javascript)
I want to "create the module, singleton or something pattern, and then roll/call multiple method in the same time".
Exmple: Yourlib.getId('elmID').setColor('somecolor').setHtml('somehtml').show().blaa.blaa.blaa
How to create the basic pattern?
var Yourlib = (function() {
var anyPrivateVar = blablabla;
anyFunctions(){
any stuff...
}
return {
setHtml: blablabla,
method2: function() {
anything...
}
getId: function() {
anything...
},
setColor: function() {
anything...
},
show: function() {
anything...
}
}
}())
How to create the pattern, so i can call/roll the method in same time?
Yourlib.getId('elmID').setColor('somecolor').setHtml('somehtml').show().blaa.blaa.blaa
return thisto the end of each of these (non-getter) methods.