From 2ab514fcd6bfe5911a5bc6e10404089effb1b922 Mon Sep 17 00:00:00 2001 From: Felix Nagel Date: Wed, 19 Dec 2012 00:20:12 +0100 Subject: [PATCH] Selectmenu: improved custom render demo CGL --- demos/selectmenu/custom_render.html | 31 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/demos/selectmenu/custom_render.html b/demos/selectmenu/custom_render.html index e6efb12d1..1aa563d61 100644 --- a/demos/selectmenu/custom_render.html +++ b/demos/selectmenu/custom_render.html @@ -16,33 +16,40 @@ $.widget( "custom.iconselectmenu", $.ui.selectmenu, { _renderItem: function( ul, item ) { - var li = $( "
  • " ).data( "ui-selectmenu-item", item ); + var li = $( "
  • " ).data( "ui-selectmenu-item", item ), + element, + span; + if ( item.disabled ) { - li.addClass( 'ui-state-disabled' ).text( item.label ); + li.addClass( "ui-state-disabled" ).text( item.label ); } else { - el = item.element; - $( "", { - html: icon = '' + item.label, + element = item.element; + span = $( "", { + style: element.attr( "style" ), + 'class': "ui-icon " + element.attr( "class" ) + }); + $( "", { + text: item.label, href: '#' - }).appendTo( li ); + }).append( span ).appendTo( li ); } return li.appendTo( ul ); } }); - var files = $('select#files').iconselectmenu({ + var files = $( "select#files" ).iconselectmenu({ dropdown: false }); - files.iconselectmenu("menuWidget").addClass("ui-menu-icons"); + files.iconselectmenu( "menuWidget" ).addClass( "ui-menu-icons" ); - var filesB = $('select#filesB').iconselectmenu({ + var filesB = $( "select#filesB" ).iconselectmenu({ dropdown: false }); - filesB.iconselectmenu("menuWidget").addClass("ui-menu-icons customicons"); + filesB.iconselectmenu( "menuWidget" ).addClass( "ui-menu-icons customicons" ); - var peopleA = $('select#peopleA').iconselectmenu(); - peopleA.iconselectmenu("menuWidget").addClass("ui-menu-icons avatar"); + var peopleA = $( "select#peopleA" ).iconselectmenu(); + peopleA.iconselectmenu( "menuWidget").addClass( "ui-menu-icons avatar" ); });