.get("childComponents") does not work or am I misunderstanding something?
-
Child components can be seen in the JSON of Panel1:
What am I doing wrong? Is there some other method that is supposed to be used to get the child components?
-
@VirtualVirgin With a few exceptions
.get
only retrieves properties that are accessible in the property editor.You can use this method to get the children. As is always the case when getting component references, this should only be used in on init (or an inline function called from on init).
for (c in Content.getAllComponents("")) { if (c.get("parentComponent") == "Panel1") Console.print(c.getId() + " is a child of the panel"); else Console.print(c.getId() + " is not a child of the panel"); }
-
@d-healey Thanks :) I guess I will have to store the component references in a panel then as I need to use them during a callback.
-
@VirtualVirgin You can store them in consts within on init or in a namespace like any other component reference.
-
@d-healey Thanks :) The components are being created and referenced in an inline function though.
-
@VirtualVirgin Ah I see, then yeah a panel is probably the way to go unless you want to return them in an array or object