Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#10154 closed defect (invalid)

HasDropDown - node attach to dopDown isn't in doc

Reported by: Mathevet julien Owned by: Nathan Toone
Priority: high Milestone: tbd
Component: Dijit Version: 1.4.0b
Keywords: Cc:
Blocked By: Blocking:


To set a node programmaticaly to this.dropDown and to avoid dojo.byId return null. I have to call dijit.popup.prepare before to add it.

Attachments (1)

test_dropDownMenu.html (5.1 KB) - added by Mathevet julien 12 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 Changed 12 years ago by Mathevet julien

For eg:


var button = new dijit.form.DropDownButton({
   label: "Ajout widget",
   name: "addWidget",
   dropDown: tabContainer,
   id: idButton,
   showLabel: true,
   tabStrip: true

comment:2 Changed 12 years ago by bill

Component: GeneralDijit
Owner: anonymous deleted

Hmm, seems like that shouldn't be necessary but can you attach a full test case using the "Attach file" button?

comment:3 Changed 12 years ago by Mathevet julien

If you call dojo.byId on a subNode of dropDown node. It always return null, unless you have clicked on it and it has called dijit.popup.prepare(this.dropDown);

I will make it, if you really want one...

comment:4 Changed 12 years ago by bill

Actually, I don't understand why you think this is a bug, you are saying the drop down works fine?

comment:5 Changed 12 years ago by Mathevet julien

When you set the dropDown node, this node is never insert inside doc. So if you try to acces by dojo.byId it will return null. Unless the method openDropDown is called first time. Then it work because this method called dijit.popup.prepare(this.dropDown), and your domNode is inserted inside doc.
may be could be add a function setDropNode which do a dijit.popup.prepare(this.dropDown). And use dojo.attr(.., "dropDown", ..) in child class. no ?

comment:6 Changed 12 years ago by Mathevet julien

it's a bug because If I would do for eg a dojo.addclass on any subNode it raises me an exception. And sometimes I have only id of this node.

comment:7 Changed 12 years ago by bill

Owner: set to Nathan Toone

I guess so, Nathan, what do you think?

comment:8 Changed 12 years ago by Nathan Toone

Resolution: invalid
Status: newclosed

If you want it attached to the doc, you can attach it yourself. The hasdropdown class is intended to be a general purpose class, and as such we don't want to add stuff to the Dom that may not ever be used - it slows down the page and uses up memory unnecesarily. The idea is that you don't add stuff until it is explicitly requested by the end user.

There are many other approaches you can take in your particular case - such as adding it to the Dom yourself, or storing a reference to the node. You could even read the node out of whatever widget has the dropdown.

Changed 12 years ago by Mathevet julien

Attachment: test_dropDownMenu.html added

comment:9 Changed 12 years ago by Mathevet julien

Ok. So I couldn't mix markup style and prog ? I added en example.
Yes to manipulate dom inside the dropDown I used dijit.popup.prepare to add it do doc.

comment:10 Changed 12 years ago by Nathan Toone

Yes - you can mix both of them...that's not what your problem here is, though. What I think might help is a bit of change to your perspective. Rather than trying to fight with the lazy loading, use it to your advantage. That is, rather than calling:


Which sets up all your drag-n-drop stuff for elements that the user may or may not even display (in the popup), set up your drag-n-drop lazily...when the user opens the dropdown. That way, you are more performant on loading (because you aren't setting up stuff that might not be used). For example, you could do something like this:

<div  dojoType="dijit.form.DropDownButton" id="cutB" showLabel="true" class="addWidgetIcon" tabStrip="true">
    <script type="dojo/method" event="openDropDown">
            this._dndInitted = true;
        this.inherited("openDropDown", arguments);
    <span>Ajout de contenu</span>

(after removing your call to init from dojo.addOnLoad)

comment:11 Changed 12 years ago by Mathevet julien

Thank's I often forget to use dojo/method or dojo/connect.

Note: See TracTickets for help on using tickets.