]> source.dussan.org Git - jquery-ui.git/commitdiff
fixed: problem with UTF-8 non-english chars as optgroup labels
authorFelix Nagel <info@felixnagel.com>
Sun, 20 Mar 2011 17:14:25 +0000 (18:14 +0100)
committerFelix Nagel <info@felixnagel.com>
Sun, 20 Mar 2011 17:14:25 +0000 (18:14 +0100)
ui/jquery.ui.selectmenu.js

index 1d876a73fc156be2976a940f08e03ad0d983834c..a1ad54b4c3d8439dc3e56d309234d992d0598a16 100644 (file)
@@ -247,7 +247,7 @@ $.widget("ui.selectmenu", {
                                        selected: $(this).attr('selected'),
                                        classes: $(this).attr('class'),
                                        typeahead: $(this).attr('typeahead'),
-                                       parentOptGroup: $(this).parent('optgroup').attr('label'),
+                                       parentOptGroup: $(this).parent('optgroup'),
                                        bgImage: o.bgImage.call($(this))
                                });
                        });             
@@ -292,16 +292,15 @@ $.widget("ui.selectmenu", {
                                });
 
                        // optgroup or not...
-                       if (selectOptionData[i].parentOptGroup) {
-                               // whitespace in the optgroupname must be replaced, otherwise the li of existing optgroups are never found
-                               var optGroupName = self.widgetBaseClass + '-group-' + selectOptionData[i].parentOptGroup.replace(/[^a-zA-Z0-9]/g, "");
-                               if (this.list.find('li.' + optGroupName).size()) {
-                                       this.list.find('li.' + optGroupName + ':last ul').append(thisLi);
+                       if ( selectOptionData[i].parentOptGroup.length ) {
+                               var optGroupName = self.widgetBaseClass + '-group-' + this.element.find( 'optgroup' ).index( selectOptionData[i].parentOptGroup );
+                               if (this.list.find( 'li.' + optGroupName ).length ) {
+                                       this.list.find( 'li.' + optGroupName + ':last ul' ).append( thisLi );
                                } else {
-                                       $('<li role="presentation" class="' + self.widgetBaseClass + '-group ' + optGroupName + '"><span class="' + self.widgetBaseClass + '-group-label">' + selectOptionData[i].parentOptGroup + '</span><ul></ul></li>')
-                                               .appendTo(this.list)
-                                               .find('ul')
-                                               .append(thisLi);
+                                       $(' <li role="presentation" class="' + self.widgetBaseClass + '-group ' + optGroupName + '"><span class="' + self.widgetBaseClass + '-group-label">' + selectOptionData[i].parentOptGroup.attr('label') + '</span><ul></ul></li> ')
+                                               .appendTo( this.list )
+                                               .find( 'ul' )
+                                               .append( thisLi );
                                }
                        } else {
                                thisLi.appendTo(this.list);