[jQuery] Re: Is there a standard way for a child object to reference a parent object?
Thanks all On May 6, 6:58 pm, Karl Rudd [EMAIL PROTECTED] wrote: The short answer is no. JavaScript doesn't have a built in idea of any sort of class hierachy. The method you talked about (passing in a reference) is one of the simplest (and probably easiest) ways to get hierachy/nesting into JavaScript. What marks is pointing too is a library that allows you to build that heirachy in a consistant manner. I haven't needed to use it so I can't vouch for it. Karl Rudd On 5/7/07, Daemach [EMAIL PROTECTED] wrote: This is more of a base javascript question - it's not specific to jQuery. In the HTML DOM, if I'm inside an iframe this refers to the local window and I can refer to my parent using parent. I just want to know if there is something similar for functions running inside of objects that are children of another object. On May 6, 5:34 pm, nick name [EMAIL PROTECTED] wrote: Hey, I just started using jquery so not to sure, however I use Base.js http://dean.edwards.name/weblog/2006/03/base/ It gives alot of oo features and solves your issue above. To do it in jquery I'II have to do some more reading Hopes this helps On May 7, 8:19 am, Daemach [EMAIL PROTECTED] wrote: I am finally figuring objects out - yay :) If I use a constructor to create a new object (car), I can refer to its properties and methods from within that object with this (this.model). If I set one if its properties (this.engine) to another new object (new engine()), is there a standard way to refer back to properties/methods in the parent object from within this new object (this.parent.model) ? I've been passing a reference to the new object (new engine(this) -- engine = function(root){ this.root = root;} ) so I can get at methods easily, but that seems messy. I don't like the thought of circular references even if they are benign :)
[jQuery] Re: Is there a standard way for a child object to reference a parent object?
Hey, I just started using jquery so not to sure, however I use Base.js http://dean.edwards.name/weblog/2006/03/base/ It gives alot of oo features and solves your issue above. To do it in jquery I'II have to do some more reading Hopes this helps On May 7, 8:19 am, Daemach [EMAIL PROTECTED] wrote: I am finally figuring objects out - yay :) If I use a constructor to create a new object (car), I can refer to its properties and methods from within that object with this (this.model). If I set one if its properties (this.engine) to another new object (new engine()), is there a standard way to refer back to properties/methods in the parent object from within this new object (this.parent.model) ? I've been passing a reference to the new object (new engine(this) -- engine = function(root){ this.root = root;} ) so I can get at methods easily, but that seems messy. I don't like the thought of circular references even if they are benign :)
[jQuery] Re: Is there a standard way for a child object to reference a parent object?
This is more of a base javascript question - it's not specific to jQuery. In the HTML DOM, if I'm inside an iframe this refers to the local window and I can refer to my parent using parent. I just want to know if there is something similar for functions running inside of objects that are children of another object. On May 6, 5:34 pm, nick name [EMAIL PROTECTED] wrote: Hey, I just started using jquery so not to sure, however I use Base.js http://dean.edwards.name/weblog/2006/03/base/ It gives alot of oo features and solves your issue above. To do it in jquery I'II have to do some more reading Hopes this helps On May 7, 8:19 am, Daemach [EMAIL PROTECTED] wrote: I am finally figuring objects out - yay :) If I use a constructor to create a new object (car), I can refer to its properties and methods from within that object with this (this.model). If I set one if its properties (this.engine) to another new object (new engine()), is there a standard way to refer back to properties/methods in the parent object from within this new object (this.parent.model) ? I've been passing a reference to the new object (new engine(this) -- engine = function(root){ this.root = root;} ) so I can get at methods easily, but that seems messy. I don't like the thought of circular references even if they are benign :)
[jQuery] Re: Is there a standard way for a child object to reference a parent object?
The short answer is no. JavaScript doesn't have a built in idea of any sort of class hierachy. The method you talked about (passing in a reference) is one of the simplest (and probably easiest) ways to get hierachy/nesting into JavaScript. What marks is pointing too is a library that allows you to build that heirachy in a consistant manner. I haven't needed to use it so I can't vouch for it. Karl Rudd On 5/7/07, Daemach [EMAIL PROTECTED] wrote: This is more of a base javascript question - it's not specific to jQuery. In the HTML DOM, if I'm inside an iframe this refers to the local window and I can refer to my parent using parent. I just want to know if there is something similar for functions running inside of objects that are children of another object. On May 6, 5:34 pm, nick name [EMAIL PROTECTED] wrote: Hey, I just started using jquery so not to sure, however I use Base.js http://dean.edwards.name/weblog/2006/03/base/ It gives alot of oo features and solves your issue above. To do it in jquery I'II have to do some more reading Hopes this helps On May 7, 8:19 am, Daemach [EMAIL PROTECTED] wrote: I am finally figuring objects out - yay :) If I use a constructor to create a new object (car), I can refer to its properties and methods from within that object with this (this.model). If I set one if its properties (this.engine) to another new object (new engine()), is there a standard way to refer back to properties/methods in the parent object from within this new object (this.parent.model) ? I've been passing a reference to the new object (new engine(this) -- engine = function(root){ this.root = root;} ) so I can get at methods easily, but that seems messy. I don't like the thought of circular references even if they are benign :)