Opened 7 years ago

Closed 7 years ago

#15408 closed enhancement (fixed)

DropDownButton: ability to subclass and programatically create drop down

Reported by: gerhard presser Owned by: bill
Priority: high Milestone: 1.9
Component: Dijit Version: 1.7.2
Keywords: Cc:
Blocked By: Blocking:

Description

I created my own DropDownButton?-sub-widget which loads it's drop down dynamically - by overriding loadDropDown(callback)

but if I want to create thw widget via markup, I also have to override _fillContent(), because the original DropDownButton? assumes, that if there's a srcNodeRef - there has to be a sub-node.

<div data-dojo-type="my.own.DropDownButton" data-dojo-props="label:'label'"></div>

I think, the dropdownbutton should handle this case out of the box...

Change History (9)

comment:1 Changed 7 years ago by bill

Component: GeneralDijit
Milestone: tbd1.8
Owner: set to bill
Status: newassigned

comment:2 Changed 7 years ago by bill

It seems like the code handles the case when the srcNodeRef doesn't contain a drop down:

startup: function(){
        if(this._started){ return; }

        // the child widget from srcNodeRef is the dropdown widget.  Insert it in the page DOM,
        // make it invisible, and store a reference to pass to the popup code.
        if(!this.dropDown && this.dropDownContainer){
                var dropDownNode = query("[widgetId]", this.dropDownContainer)[0];
                this.dropDown = registry.byNode(dropDownNode);
                delete this.dropDownContainer;
        }
        if(this.dropDown){
                popup.hide(this.dropDown);
        }

        this.inherited(arguments);
},

(specifically with the if(this.dropDown))

Is the issue in this code in fill content, getting the label?

var nodes = query("*", this.srcNodeRef);
this.inherited(arguments, [nodes[0]]);

I guess technically your example above should work, but why didn't you just do this?

<div data-dojo-type="my.own.DropDownButton">label</div>

comment:3 Changed 7 years ago by Colin Snover

Milestone: 1.82.0

1.8 is frozen. Move all enhancements to next release. If you need an exemption from the freeze for this ticket, contact me immediately.

comment:4 Changed 7 years ago by bill

Owner: changed from bill to gerhard presser
Status: assignedpending

comment:5 Changed 7 years ago by gerhard presser

Status: pendingnew
<div data-dojo-type="my.own.DropDownButton">label</div>

does not work for me.

in fact the startup() code fails if no dropDown is present

...
var dropDownNode = query("[widgetId]", this.dropDownContainer)[0];
this.dropDown = registry.byNode(dropDownNode); //exception - dropDownNode is null
...

I think saving the srcNodeRef pointer in the _fillContent() function is the problem. maybe

this.dropDownContainer = nodes[1];

is better?

comment:6 Changed 7 years ago by bill

Summary: dropdownbutton without nested dropdown-widgetDropDownButton: ability to subclass and programatically create drop down

OK, makes sense, I guess it needs to wait for 2.0 though.

comment:7 Changed 7 years ago by bill

Milestone: 2.01.9
Owner: changed from gerhard presser to bill
Status: newassigned

comment:8 Changed 7 years ago by bill

Priority: undecidedhigh

comment:9 Changed 7 years ago by bill

Resolution: fixed
Status: assignedclosed

In [30477]:

There may not be a drop down widget specified in the markup. Fixes #15408 !strict.

Note: See TracTickets for help on using tickets.