Opened 10 years ago

Closed 10 years ago

#10219 closed defect (wontfix)

Creating dijits in another dijit's buildRendering means startup() isn't called, unless _earlyTemplatedStartup: true?

Reported by: Nick Fenwick Owned by:
Priority: high Milestone: tbd
Component: Dijit Version: 1.4.0b
Keywords: Cc:
Blocked By: Blocking:

Description

This was previously mentioned in #9348. I may be misunderstanding the best way to do what I'm trying to do. I have seen that a DropDownButton? fails to popup its TooltipDialog? unless I use an obscure _earlyTemplatedStartup switch introduced in 1.4, but you may argue it's because of the way I'm creating my dijits.

I have two dijits, lets say an Outer dijit, which may or may not want to include an Inner dijit. The Inner dijit is quite complicated, so my method for including it is to have a stub <div dojoAttachPoint='insertHere'/> in the Outer template, and Outer.buildRendering creates an instance of Inner with "var d = new Inner({}, this.insertHere)". In the cases where I don't want to show Inner, I have no data for it at all and it makes no sense to show it, so I don't want to include it in the DOM at all.

It is my Inner dijit that contains a DropDownButton? in its template, which is where the problem occurs.

That method of creating a child dijit in buildRendering seems to prevent the Button.js:startup() method from being fired, unless the Inner dijit declares _earlyTemplatedStartup: true.

This only seems to happen with 1.4, I tested against 1.3.2 on a CDN and everything worked fine. I am not sure how to submit a test case using a CDN with 1.4 beta, so I'll just attach my jsp, which has a "dojoIncludes.jsp" include which brings in my 1.4 beta dojo.

So on my test page there are:

1/ an instance of my Inner created programatically. It works fine.

2/ an instance of my Outer created prog., which creates an Inner in its buildRendering. That Inner dropdown does not work, unless you change the code to set _earlyTemplatedStartup: true.

3/ a basic dropdownbutton in markup, to show the default non-templated behaviour.

Perhaps I should be bringing in my optional dijit (Inner) into the Outer dijits template in another way?

Attachments (1)

dropdownbutton.jsp (1.6 KB) - added by Nick Fenwick 10 years ago.
Sample file (with broken dojo includes, needs 1.4 beta)

Download all attachments as: .zip

Change History (2)

Changed 10 years ago by Nick Fenwick

Attachment: dropdownbutton.jsp added

Sample file (with broken dojo includes, needs 1.4 beta)

comment:1 Changed 10 years ago by bill

Resolution: wontfix
Status: newclosed

Hmm, well yes, that isn't supported directly. There are a lot of ways to get it to work though. Maybe the most proper way would be in your buildRendering() function to set:

this._startupWidgets = [ dijitWithDropdown ];

(That's assuming that you aren't using widgetsInTemplate; if you are then this._startupWidgets[] will already exist and you can just this._startupWidgets.push(dijitWithDropdown) instead.)

Seems like you'd also want to push dijitWithDropdown onto this._supportingWidgets so it gets destroyed when your outerWidget is destroyed.

Hopefully that fixes the problem for you? I'm going to close this ticket for now but let me know if there's still a problem. I can see that this could be considered a back-compat break but I don't see a way around it; the changes were needed to fix a bunch of other problems.

Note: See TracTickets for help on using tickets.