]> source.dussan.org Git - jquery-ui.git/commitdiff
Selectmenu; improve HTML building in custom render demo
authorFelix Nagel <info@felixnagel.com>
Tue, 30 Apr 2013 21:40:53 +0000 (23:40 +0200)
committerFelix Nagel <info@felixnagel.com>
Tue, 30 Apr 2013 21:40:53 +0000 (23:40 +0200)
demos/selectmenu/custom_render.html

index 03f873d198652b7ec3d1d4a5fd3410ee9d027176..941c94da649e78f508b2793468de61e163f5dd65 100644 (file)
        $(function() {
                $.widget( "custom.iconselectmenu", $.ui.selectmenu, {
                        _renderItem: function( ul, item ) {
-                               var element, span,
+                               var a, span,
                                        li = $( "<li>" );
 
                                if ( item.disabled ) {
                                        li.addClass( "ui-state-disabled" ).text( item.label );
                                } else {
-                                       element = item.element;
+                                       a = $( "<a>", {
+                                               text: item.label,
+                                               href: "#"
+                                       }).appendTo( li );
                                        span = $( "<span>", {
-                                               style: element.attr( "style" ),
-                                               "class": "ui-icon " + element.attr( "class" )
-                                       });
-                                       $( "<a>", {
-                                                       text: item.label,
-                                                       href: "#"
-                                       })
-                                       .append( span )
-                                       .appendTo( li );
+                                               style: item.element.attr( "style" ),
+                                               "class": "ui-icon " + item.element.attr( "class" )
+                                       }).appendTo( a );
                                }
 
                                return li.appendTo( ul );