Opened 13 years ago

Closed 12 years ago

Last modified 11 years ago

#9072 closed enhancement (fixed)

DropDownButton should provide listeners to notify before the dropDown is shown or hidden.

Reported by: Phil DeJarnett Owned by:
Priority: low Milestone: 1.4
Component: Dijit - Form Version: 1.3.0
Keywords: DropDownButton listener Cc:
Blocked By: Blocking:


It would be nice to have the ability to listen for the showing or hiding of the dropDown on dijit.form.DropDownButton?. Specifically, there are two notifications that would be nice: onBeforeOpen and onBeforeClose.

I use these to pre-fill in the values on a shared ToolTipDialog? when it is being shown, and then to save the values back when it is hidden.

They could simply be called with no arguments at the top of _openDropDown and _closeDropDown, respectively. Alternatively, they could be used to override the default behavior (such as preventing the dropDown from closing when a ToolTipDialog? has invalid fields). I think simply calling the methods is enough.

Change History (7)

comment:1 Changed 13 years ago by Phil DeJarnett

My customized class:

		[dijit.form.DropDownButton], {
	// Called when the dropdown is shown
	onBeforeOpen: function() { },

	// Called when the dropdown is hidden
	onBeforeClose: function() { },
	// Overridden to provide a listener
	_openDropDown: function() {
	// Overridden to provide a listener
	_closeDropDown: function(focus) {
		if (this._opened) {

comment:2 Changed 12 years ago by Nathan Toone

Resolution: fixed
Status: newclosed

Hooks for specifying whether or not the dropdown is loaded (isLoaded), loading (loadDropDown), and toggling (toggleDropDown) all now exist in DropDownButton? (as well as any other widgets that use dijit._HasDropDown.

comment:3 Changed 12 years ago by bill

Milestone: tbd1.4

comment:4 Changed 12 years ago by Phil DeJarnett

I looked at the trunk for the changes. I don't think the hooks mentioned cover my request, but I could be wrong.

It appears to me that the toggleDropDown method would have to be dojo.connected to, and therefore would only operate after the dropdown has already been shown.

What I really want is the ability to modify the dropdown before it is displayed, as you can see in the example. (That's why I call the methods onBeforeOpen and onBeforeClose.)

I think that the openDropDown and closeDropDown methods should both have a callback (that is processed before anything else happens) so it isn't necessary to subclass a widget just to modify a drop down before it is shown or process it after it is closed.

If I am wrong, then I apologize for misunderstanding.

BTW: I really like the fact that multiple widgets are now sharing this code!

comment:5 Changed 12 years ago by Nathan Toone

For your specific case, (loading your dropdown before it is displayed), you can override the loadDropDown function (you may need to override isLoaded to return false if it's "out-of-sync".)

I'm not sure of the utility of an onBeforeClose function.

comment:6 Changed 12 years ago by Phil DeJarnett

I understand now about how loadDropDown/isLoaded makes sense.

I explained how I use onBeforeClose in my original report. When the TooltipDialog? is hidden from the button, I process the form data (saving it). But it looks like I'll have to continue subclassing the DropDownButton?, anyway!

(At least the new methods are public, so they should be less likely to change again.)

comment:7 Changed 11 years ago by bill

Component: DijitDijit - Form
Note: See TracTickets for help on using tickets.