Fix for issue 1262

This commit is contained in:
Ivan Rubanov 2011-03-21 22:21:53 +08:00 committed by Scott Jehl
parent f22b7c8395
commit b35274a8a4

View file

@ -22,7 +22,7 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
nativeMenu: false
},
_create: function(){
var self = this,
o = this.options,
@ -33,7 +33,12 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
selectID = select.attr( "id" ),
label = $( "label[for="+ selectID +"]" ).addClass( "ui-select" ),
//IE throws an exception at options.item() function when
//there is no selected item
//select first in this case
selectedIndex = select[0].selectedIndex == -1 ? 0 : select[0].selectedIndex,
button = ( self.options.nativeMenu ? $( "<div/>" ) : $( "<a>", {
"href": "#",
"role": "button",
@ -41,7 +46,7 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
"aria-haspopup": "true",
"aria-owns": menuId
}) )
.text( $( select[0].options.item(select[0].selectedIndex) ).text() )
.text( $( select[0].options.item( selectedIndex ) ).text() )
.insertBefore( select )
.buttonMarkup({
theme: o.theme,