Menu: Allow changing icons option after creation. Fixes #8927 - Menu: Can't change icons option after init

This commit is contained in:
Jörn Zaefferer 2012-12-27 17:23:25 +01:00
parent 0d53fbfd0b
commit 2c3d311f90
2 changed files with 13 additions and 1 deletions

View File

@ -41,9 +41,12 @@ test( "{ disabled: false }", function() {
});
test( "{ icons: default }", function() {
expect( 1 );
expect( 2 );
var element = $( "#menu2" ).menu();
equal( element.find( ".ui-menu-icon" ).attr( "class" ), "ui-menu-icon ui-icon ui-icon-carat-1-e" );
element.menu("option", "icons.submenu", "ui-icon-triangle-1-e");
equal( element.find( ".ui-menu-icon" ).attr( "class" ), "ui-menu-icon ui-icon ui-icon-triangle-1-e" );
});
test( "{ icons: { submenu: 'custom' } }", function() {

View File

@ -343,6 +343,15 @@ $.widget( "ui.menu", {
}[ this.options.role ];
},
_setOption: function( key, value ) {
if ( key === "icons" ) {
this.element.find( ".ui-menu-icon" )
.removeClass( this.options.icons.submenu )
.addClass( value.submenu );
}
this._super( key, value );
},
focus: function( event, item ) {
var nested, focused;
this.blur( event, event && event.type === "focus" );