Opened 7 years ago

Closed 7 years ago

#15066 closed enhancement (fixed)

childWidget.placeAt(parentWidget) should call childWidget.startup()

Reported by: bill Owned by: bill
Priority: undecided Milestone: 1.8
Component: Dijit Version: 1.7.2
Keywords: Cc: ykami, cjolif
Blocked By: Blocking:

Description (last modified by bill)

If parentWidget is already started, then childWidget.placeAt(parentWidget) should call childWidget.startup(), same as happens with addChild().

In actuality, childWidget.startup() is only called in parentWidget extends dijit._Container and thus has an addChild() method.

Change History (6)

comment:1 Changed 7 years ago by bill

Milestone: tbd1.8
Owner: set to bill
Status: newassigned
Type: defectenhancement

comment:2 Changed 7 years ago by bill

Cc: ykami cjolif added

comment:3 Changed 7 years ago by bill

Description: modified (diff)

comment:4 Changed 7 years ago by ben hockey

i'm still confused about what this ticket is tracking.

childWidget.placeAt(parentWidget) calls parentWidget.addChild(childWidget) which for a parentWidget that inherits from _Container it already calls startup. is there some specific addChild functions in classes that don't inherit from _Container that aren't calling startup? i couldn't find any in dijit.

are you suggesting that the code in placeAt should also try to call startup in addition to the startup call in addChild?

maybe you're suggesting that if placeAt is passed a DOM node it should see if the node has an enclosing widget and then start the child widget - ie you meant to put childWidget.placeAt(parentWidget.containerNode) in the description? that's interesting but doesn't seem right. i may have a TabContainer? and i want to place several children in my containerNode via child.placeAt(this.containerNode) but i only want child.startup to be called when the child is first shown. this would break if you're suggesting that childWidget.placeAt(parentWidget.containerNode) should call startup.

i think that for consistency addChild should always be managing the call to startup so that widgets added via parent.addChild(child); work the same as child.placeAt(parent); and placeAt should just call addChild (as it does now). this also allows for a delayed startup to be managed by the container as necessary.

unless you mean childWidget.placeAt(aDomNode) to call startup then it seems the only thing left is to ensure that all addChild functions call startup. a quick search of dojox shows the following exceptions

  • dojox/app/scene
  • dojox/widget/TitleGroup

comment:5 in reply to:  4 Changed 7 years ago by bill

Replying to neonstalwart:

i'm still confused about what this ticket is tracking.

childWidget.placeAt(parentWidget) calls parentWidget.addChild(childWidget)

Sometimes it does, sometimes it doesn't. That addChild() is inside an if() statement. I am talking about the }else{ branch.

are you suggesting that the code in placeAt should also try to call startup in addition to the startup call in addChild?

No.

maybe you're suggesting that if placeAt is passed a DOM node it should see if the node has an enclosing widget and then start the child widget -

Not really. I'm talking about when placeAt() is passed a widget that doesn't have an addChild() method.

comment:6 Changed 7 years ago by bill

Resolution: fixed
Status: assignedclosed

In [28251]:

Allow placeAt() to take an id of a widget or DOMNode, rather than an id refers to a DOMNode. This will (hopefully) avoid confusion given that a widget's id == it's DOMNode's id.

If the parent widget is started then call startup() on the child widget automatically, even if the parent doesn't have an addChild() method.

Also upgrading test to AMD.

Fixes #14946, #15066 !strict.

Note: See TracTickets for help on using tickets.