Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

referencing a parent object

Status
Not open for further replies.

UCENwebster

Programmer
Jun 7, 2002
18
US
Hey everybody,
I have an object within an object, (a child object, if you will), and I'm trying to find a way to reference the parent object from the child object and store it as a variable in the child, so that I can reference back and forth between the two, like so...

var v = new newObject();

function newObject() {
this.childObject = new newChildObject();
}
function newChildObject() {
this.parentObject = ....
this.parentObject.anonymousFunction();
}

But I don't know how to get the parent.
I've tried doing this....

var v = new newObject();

function newObject() {
this.childObject = new newChildObject();
this.childObject.parentObject = this;
}

But it doesn't work either!
Does anybody know a way to keep track of a parent object in javascript (not a parent object in HTML)??? This problem is killing me...
Webster
 
What about this.ParentElement ?
Should return you a refrence to the parent object if I remember correctly.
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top