UCENwebster
Programmer
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
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