Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#10662 closed bug (fixed)

Selectmenu: Calling refresh() after removing all options throws an error

Reported by: janom Owned by:
Priority: minor Milestone: 1.12.0
Component: ui.selectmenu Version: 1.11.1
Keywords: Cc:
Blocked by: Blocking:

Description

after remove all options from select and then call refresh on selectmenu, i get error: "this.menuItems is undefined" http://jsfiddle.net/janom/w0q994gu/

Change History (13)

comment:1 Changed 8 years ago by tj.vantoll

Status: newopen
Summary: selectmenu refresh empty options throw errorSelectmenu: Calling refresh() after removing all options throws an error

comment:2 Changed 8 years ago by janom

I changed selectmenu javascript... can you please check if my solutions is right? in _refreshMenu: function() i change from this lines:

		if ( !options.length ) {
			return;
		}

		this._parseOptions( options );
		this._renderMenu( this.menu, this.items );

		this.menuInstance.refresh();
		this.menuItems = this.menu.find( "li" ).not( ".ui-selectmenu-optgroup" );

to this lines:

		this._parseOptions( options );
		this._renderMenu( this.menu, this.items );

		this.menuItems = this.menu.find( "li" ).not( ".ui-selectmenu-optgroup" );

		if ( !options.length ) {
			return;
		}

		this.menuInstance.refresh();

and in open: function( event ) i change this line:

		if ( !this.menuItems ) {

to this line:

		if ( !this.menuItems || this.menuItems.length==0) {
Last edited 8 years ago by janom (previous) (diff)

comment:3 Changed 8 years ago by tj.vantoll

If you're interested in submitting a patch please do so as a pull request.

comment:5 Changed 8 years ago by Scott González

Resolution: fixed
Status: openclosed

Selectmenu: Better handling when there are no options

Fixes #10662 Closes gh-1370 Closes gh-1423

Changeset: 65584c1640f8c7430587738c3c4cd7dd8010a2a5

comment:6 Changed 8 years ago by Scott González

Milestone: none1.12.0

comment:7 Changed 8 years ago by Scott González

#12262 is a duplicate of this ticket.

comment:8 Changed 7 years ago by alexandis

Excuse me, I'm experiencing the same problem on jquery UI 1.11.4 now, downloaded from official link. How come that the code there is old - not the one that is present in the fix? I've tried to replace piece of code, related to selectmenu, from selectmenu.js from github. But then getting exception here: var item = ui.item.data("ui-selectmenu-item"); in focus event, since ui.item is empty object...

Last edited 7 years ago by alexandis (previous) (diff)

comment:9 Changed 7 years ago by Scott González

The milestone on this ticket is 1.12.0, which means that the fix wouldn't be included in 1.11.4.

comment:10 in reply to:  9 Changed 7 years ago by alexandis

Replying to scottgonzalez:

The milestone on this ticket is 1.12.0, which means that the fix wouldn't be included in 1.11.4.

Ok. Then how should i fix the issue with refreshing after removing options? Thanks.

comment:11 Changed 7 years ago by Scott González

Upgrade to the latest pre-release of 1.12.0.

comment:12 in reply to:  11 Changed 7 years ago by alexandis

Replying to scottgonzalez:

Upgrade to the latest pre-release of 1.12.0.

Thank you. I've replaced 1.11.4 with 1.12 release candidate, but now I got exception when trying to create dialog object (where 1.11.4 worked properly): effectMethod is undefined (effectMethod = $.effects.effect[ args.effect ], args.effect is true, not some effect name). Unfortunately, it's not possible to send call stack from Firebug...

comment:13 Changed 7 years ago by Scott González

Please create a new ticket as this is unrelated. Thanks.

Note: See TracTickets for help on using tickets.