From 2c3d311f90281e95827708e2e8d0e52832a437de Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B6rn=20Zaefferer?= Date: Thu, 27 Dec 2012 17:23:25 +0100 Subject: [PATCH] Menu: Allow changing icons option after creation. Fixes #8927 - Menu: Can't change icons option after init --- tests/unit/menu/menu_options.js | 5 ++++- ui/jquery.ui.menu.js | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/unit/menu/menu_options.js b/tests/unit/menu/menu_options.js index 2c8749e3c..e3977e6ce 100644 --- a/tests/unit/menu/menu_options.js +++ b/tests/unit/menu/menu_options.js @@ -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() { diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 7f37b6b06..8d99272d0 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -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" ); -- 2.39.5