From 666927ba916d3f3f90e48677e4884ffd0d7cc398 Mon Sep 17 00:00:00 2001 From: Felix Nagel Date: Mon, 29 Apr 2013 23:05:07 +0200 Subject: [PATCH] Selectmenu: add renderItemData method similar to autocomplete --- demos/selectmenu/custom_render.html | 2 +- ui/jquery.ui.selectmenu.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/demos/selectmenu/custom_render.html b/demos/selectmenu/custom_render.html index 09e6811f0..03f873d19 100644 --- a/demos/selectmenu/custom_render.html +++ b/demos/selectmenu/custom_render.html @@ -16,7 +16,7 @@ $.widget( "custom.iconselectmenu", $.ui.selectmenu, { _renderItem: function( ul, item ) { var element, span, - li = $( "
  • " ).data( "ui-selectmenu-item", item ); + li = $( "
  • " ); if ( item.disabled ) { li.addClass( "ui-state-disabled" ).text( item.label ); diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js index ffcfcb852..4ec8fcd8d 100644 --- a/ui/jquery.ui.selectmenu.js +++ b/ui/jquery.ui.selectmenu.js @@ -163,11 +163,11 @@ $.widget( "ui.selectmenu", { var item, options = this.element.find( "option" ); - + if ( !options.length ) { return; } - + this._readOptions( options ); this._renderMenu( this.menu, this.items ); @@ -235,12 +235,16 @@ $.widget( "ui.selectmenu", { }).appendTo( ul ); currentOptgroup = item.optgroup; } - that._renderItem( ul, item ); + that._renderItemData( ul, item ); }); }, + _renderItemData: function( ul, item ) { + return this._renderItem( ul, item ).data( "ui-selectmenu-item", item ); + }, + _renderItem: function( ul, item ) { - var li = $( "
  • " ).data( "ui-selectmenu-item", item ), + var li = $( "
  • " ), a = $( "", { href: "#" }); if ( item.disabled ) { -- 2.39.5