mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-05-17 11:01:06 +00:00
create selectOptions method so the values stay current across dom changes Fixes #2410
This commit is contained in:
parent
0b83cf8d60
commit
729757b465
2 changed files with 9 additions and 6 deletions
|
|
@ -13,7 +13,7 @@
|
|||
label = widget.label,
|
||||
thisPage = widget.select.closest( ".ui-page" ),
|
||||
screen = $( "<div>", {"class": "ui-selectmenu-screen ui-screen-hidden"} ).appendTo( thisPage ),
|
||||
selectOptions = widget.select.find("option"),
|
||||
selectOptions = widget._selectOptions(),
|
||||
isMultiple = widget.isMultiple = widget.select[ 0 ].multiple,
|
||||
buttonId = selectID + "-button",
|
||||
menuId = selectID + "-menu",
|
||||
|
|
@ -108,7 +108,7 @@
|
|||
// index of option tag to be selected
|
||||
var oldIndex = self.select[ 0 ].selectedIndex,
|
||||
newIndex = self.list.find( "li:not(.ui-li-divider)" ).index( this ),
|
||||
option = self.selectOptions.eq( newIndex )[ 0 ];
|
||||
option = self._selectOptions().eq( newIndex )[ 0 ];
|
||||
|
||||
// toggle selected status on the tag for multi selects
|
||||
option.selected = self.isMultiple ? !option.selected : true;
|
||||
|
|
@ -206,7 +206,7 @@
|
|||
var self = this,
|
||||
select = this.element,
|
||||
isMultiple = this.isMultiple,
|
||||
options = this.selectOptions = select.find( "option" ),
|
||||
options = this._selectOptions(),
|
||||
selected = this.selected(),
|
||||
// return an array of all selected index's
|
||||
indicies = this.selectedIndices();
|
||||
|
|
|
|||
|
|
@ -55,6 +55,10 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
|
|||
}, 40);
|
||||
},
|
||||
|
||||
_selectOptions: function() {
|
||||
return this.select.find( "option" );
|
||||
},
|
||||
|
||||
// setup items that are generally necessary for select menu extension
|
||||
_preExtension: function(){
|
||||
this.select = this.element.wrap( "<div class='ui-select'>" );
|
||||
|
|
@ -62,7 +66,6 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
|
|||
this.label = $( "label[for='"+ this.selectID +"']" ).addClass( "ui-select" );
|
||||
this.isMultiple = this.select[ 0 ].multiple;
|
||||
this.options.theme = this._theme();
|
||||
this.selectOptions = this.select.find( "option" );
|
||||
},
|
||||
|
||||
_create: function() {
|
||||
|
|
@ -153,14 +156,14 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
|
|||
},
|
||||
|
||||
selected: function() {
|
||||
return this.selectOptions.filter( ":selected" );
|
||||
return this._selectOptions().filter( ":selected" );
|
||||
},
|
||||
|
||||
selectedIndices: function() {
|
||||
var self = this;
|
||||
|
||||
return this.selected().map( function() {
|
||||
return self.selectOptions.index( this );
|
||||
return self._selectOptions().index( this );
|
||||
}).get();
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue