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

Commit ccd160d

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 d91c529 commit ccd160d

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
@@ -193,13 +193,16 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
193193
},
194194

195195
setButtonText: function() {
196-
var self = this, selected = this.selected();
196+
var self = this, selected = this.selected(), cls = [self.select.attr("class")];;
197197

198-
this.button.find( ".ui-btn-text" ).text( function() {
198+
this.button.find( ".ui-btn-text" ).html( function() {
199+
199200
if ( !self.isMultiple ) {
200-
return selected.text();
201+
cls.push(selected.attr("class"));
202+
return $("<span/>", {"class": cls.join(' ')}).text(selected.text());
201203
}
202204

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

0 commit comments

Comments
 (0)