Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#18537 closed defect (fixed)

Programmatic example for diijt/form/DropDownButton in Reference Guide isn't working

Reported by: Carmelo Woodgett Owned by:
Priority: undecided Milestone: 1.11
Component: Documentation Version: 1.10.4
Keywords: Cc:
Blocked By: Blocking:

Description

From documentation feedback:

Hello, the script in "Programmatic example" give: "TypeError?: button is undefined" For me it is define by: "var button = new DropDownButton? ..." So I don't understand why Thank you.

Yann

Change History (8)

comment:1 Changed 5 years ago by bill

Hmm, well one mistake in that example is that it's calling startup() before the widget is attached to the document. Actually it makes the same mistake twice because it does that for the Menu too.

comment:2 Changed 5 years ago by bill

Component: Dijit - FormDocumentation

comment:3 Changed 5 years ago by Carmelo Woodgett

Yeah, I think I see what you're saying. I submitted a PR to fix it already by calling the startup() after the button is instantiated and it's working:

        var button = new DropDownButton({
            label: "hello!",
            name: "programmatic2",
            dropDown: menu,
            id: "progButton"
        });
        button.startup();

        dom.byId("dropDownButtonContainer").appendChild(button.domNode);

However, are you saying that it should be written this way:

        var button = new DropDownButton({
            label: "hello!",
            name: "programmatic2",
            dropDown: menu,
            id: "progButton"
        });

        dom.byId("dropDownButtonContainer").appendChild(button.domNode);
        button.startup();

comment:4 Changed 5 years ago by bill

Right, the second way is technically correct, although IIRC most/all form widgets don't really need the startup() call at all.

BTW I don't see any PR's from you in https://github.com/dojo/docs/pulls.

comment:5 Changed 5 years ago by bill

Milestone: tbd1.11
Resolution: fixed
Status: newclosed

Oh I see, your PR (although incorrect) was already pushed as https://github.com/dojo/docs/commit/fcadd5c227a446d6d46d252fc982b465fd71e463.

I'll fix that. Anyway, glad to hear that the example is now working.

comment:6 Changed 5 years ago by bill

PS: OK, all the startup() calls were messed up. I fixed in https://github.com/dojo/docs/commit/9d90a5193ffcab1f7d8de7807264d4bbf3cb377d. Hopefully I didn't make any typos.

comment:7 Changed 5 years ago by Carmelo Woodgett

Sorry, I mixed up the commits somehow. Thanks for taking a look.

comment:8 Changed 5 years ago by bill

No worries. Actually, AFAIK you didn't mess up anything (except for calling startup() before the widget was attached to the document). Anyway thanks for pointing out that all the examples were broken.

Note: See TracTickets for help on using tickets.