:: Forum >>

$owner property

Alex,

If I add one control to another via obj.setContent("html", newObj) does that set the $owner of newObj to point to obj? I am trying to "climb the ladder" up the chain to get to a given "level" but the chain seems to break just a few steps into my itteration. It looks like it's breaking at the control level. If $owner is not set, how would you suggest that I get to a parent object up the hierarchy when the number of levels is unknown? What I am trying to find out is a property in one of the top most parent controls that I have created. Any suggestion would be great.

Thanks
Jim Hunter
Tuesday, January 17, 2006
Jim,

$owner is set for templates and refers to the control where the template is defined. The control might not be an immediate parent of the template element in DOM tree because you can inject template html wherever you want.

There is also _parent property which is set when you call setContent method and it corresponds to parentNode/parentElement in html tree.

Some warning:
all methods/properties starting with $ or _ are considered 'private' (i.e. use it on your own risk :-)
Alex (ActiveWidgets)
Sunday, January 22, 2006
Alex,

when creating new controls it practically impossible not to use $owner. Perhaps, there should be a documented function in the API for this?
Dmitry
Sunday, January 22, 2006
I agree with Dmitry, I need to be able to easily get the 'parent' or 'owner' (I don't care what we call it), of any control. It doesn't matter to me if it is a stand alone control (parent = null or "document"), a control added to another control, or a template control inside a custom control. Coming from a component based world, I use this property all the time and I guess I would have difficulty creating complex controls and pages without knowing this information.

Thanks Alex for the hint about _parent, I'll give it a go for now.
Jim Hunter (www.FriendsOfAW.com)
Sunday, January 22, 2006

This topic is archived.


Back to support forum

Forum search