Skip to content

Instantly share code, notes, and snippets.

Created May 24, 2011 06:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/988208 to your computer and use it in GitHub Desktop.
Save anonymous/988208 to your computer and use it in GitHub Desktop.
Patch for issue #106
diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js
index deb7b41..b84661c 100644
--- a/ui/jquery.ui.selectmenu.js
+++ b/ui/jquery.ui.selectmenu.js
@@ -260,7 +260,20 @@ $.widget("ui.selectmenu", {
// write li's
for (var i = 0; i < selectOptionData.length; i++) {
- var thisLi = $('<li role="presentation"' + (selectOptionData[i].disabled ? ' class="' + this.namespace + '-state-disabled' + '"' : '' ) + '><a href="#" tabindex="-1" role="option"' + (selectOptionData[i].disabled ? ' aria-disabled="true"' : '' ) + ' aria-selected="false"' + (selectOptionData[i].typeahead ? ' typeahead="' + selectOptionData[i].typeahead + '"' : '' ) + '>'+ selectOptionData[i].text +'</a></li>')
+
+ var thisLiAttr = {role : 'presentation'};
+ if (selectOptionData[i].disabled) {
+ thisLiAttr['class'] = this.namespace + '-state-disabled';
+ }
+
+ var thisAAttr = {href : '#', tabindex : -1, role : 'option','aria-selected' : false, 'aria-disabled' : selectOptionData[i].disabled};
+ if (selectOptionData[i].typeahead) {
+ thisAAttr['typeahead'] = selectOptionData[i].typeahead;
+ }
+
+ var thisA = $('<a/>', thisAAttr);
+ thisA.append(selectOptionData[i].text);
+ var thisLi = $('<li/>', thisLiAttr)
.data('index', i)
.addClass(selectOptionData[i].classes)
.data('optionClasses', selectOptionData[i].classes || '')
@@ -292,7 +305,7 @@ $.widget("ui.selectmenu", {
$(this).addClass(activeClass);
}
$(this).removeClass(self.widgetBaseClass + '-item-focus ui-state-hover');
- });
+ }).append(thisA);
// optgroup or not...
if ( selectOptionData[i].parentOptGroup.length ) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment