View Single Post
Old 04-26-2010, 07:19 PM   PM User | #1
jschrend
New to the CF scene

 
Join Date: Apr 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
jschrend is an unknown quantity at this point
Smile Nested Methods and Properties in JavaScript

Hi all! I'm pretty new to JavaScript and completely new to this forum. I'm James.

Well uh, I'm not sure how to...

I wanted to make something like this using javascript...

Code:
myObject.someMethod('something').anotherProperty
much like the

Code:
document.getElementById('someId').style.morestuff
But the thing is, I've been around every DOM whatnot I can find, I just can't seem to make it work.

I kinda need it to make my own DOM for some API i'm writing. So I can write like...

Code:
function someGreatAPI(){
     this.property1='';
     this.property2='';
     //...
     this.method1 = function(var1){            //this should make my firstMethod
           this.nestedProperty = 0;
           this.nestedMethod = someFunction;  //firstMethods nested method

     }
}

//so I can use it like...

var obj = new someGreatAPI();
obj.method1(10).nestedMethod();
It has to be possible, it's possible with document.getelementbyid, right? it has to be.

Thanks in advance.

Last edited by jschrend; 04-26-2010 at 10:07 PM.. Reason: Solved!
jschrend is offline   Reply With Quote