![]() Topic awaiting preservation: Objects in Objects (Page 1 of 1) |
|
---|---|
Maniac (V) Inmate From: Brisbane, Australia |
![]() Is it safe have objects that build other objects? |
Bipolar (III) Inmate From: schillmania.com |
![]() I think this works OK, it just messes with your head a bit. Like reading what you said, I had to go through it a few times! |
Maniac (V) Inmate From: Brisbane, Australia |
![]() Yup, that's exactly the answer I was looking for. Thanks a heap. |
Maniac (V) Mad Scientist From: New California |
![]() I was just doing that very thing the other day, Drac. I built some objects with data and functions within another master object. I ran into the same problem of not knowing how this would work. I found that the this refers only to the object it is currently in just like Scott says. But I also needed to reference the parent object from the children. I found that "parent.whatever" worked just fine from the child. |
Maniac (V) Inmate From: Brisbane, Australia |
![]() Hmm... Something still seems to be really really wrong here. It's should be wrong but it just ain't. |
Maniac (V) Mad Scientist From: New California |
![]() Hours spent struggling with Javascript code and all sorts of frustrating behaviors... it's the good life. |
Maniac (V) Inmate From: Brisbane, Australia |
![]() Hah! Yeah, the more frustrating, the more rewarding it is when you finally figure out a workable solution. code: function makeElement(tag,id,style) {
|
Nervous Wreck (II) Inmate From: Utreg, NL |
![]() As far as I know "this" always refers to the current scope. So when your code is currently in a chain of methods beloning to some object instance, "this" refers to that object. When setting an interval, the method is called globally, and then "this" refers to "window". code: // custom object scope
code: // custom object scope
code: var scope = this;
code: ...
|
Maniac (V) Inmate From: Brisbane, Australia |
![]() *head begins to melt* |
Bipolar (III) Inmate From: Amsterdam |
![]() Hmz, |
Maniac (V) Inmate From: Brisbane, Australia |
![]() Woohoo!!! |