Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 7651fd9

Browse files
dotnetwisejohnbender
authored andcommitted
The button's text should preserve the original css class of the select and the selected option. This way you can customize it with i.e. images.
This change is along with this one: #3480 (commits) For a demo: http://www.dotnetwise.com/tryAndError/jquery.mobile/select.filter/
1 parent 575d7ee commit 7651fd9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

js/jquery.mobile.forms.select.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,16 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
198198
},
199199

200200
setButtonText: function() {
201-
var self = this, selected = this.selected();
201+
var self = this, selected = this.selected(), cls = [self.select.attr("class")];;
202202

203-
this.button.find( ".ui-btn-text" ).text( function() {
203+
this.button.find( ".ui-btn-text" ).html( function() {
204+
204205
if ( !self.isMultiple ) {
205-
return selected.text();
206+
cls.push(selected.attr("class"));
207+
return $("<span/>", {"class": cls.join(' ')}).text(selected.text());
206208
}
207209

210+
//TODO: apply the span as above to preserve the css-class of the original select
208211
return selected.length ? selected.map( function() {
209212
return $( this ).text();
210213
}).get().join( ", " ) : self.placeholder;

0 commit comments

Comments
 (0)