Permalink
Browse files

The button's text should preserve the original css class of the selec…

…t 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/
  • Loading branch information...
1 parent 575d7ee commit 7651fd977463df5b670bb1143dd02255eea633ba @adaptabi adaptabi committed with johnbender Jan 24, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 js/jquery.mobile.forms.select.js
@@ -198,13 +198,16 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
},
setButtonText: function() {
- var self = this, selected = this.selected();
+ var self = this, selected = this.selected(), cls = [self.select.attr("class")];;
- this.button.find( ".ui-btn-text" ).text( function() {
+ this.button.find( ".ui-btn-text" ).html( function() {
+
if ( !self.isMultiple ) {
- return selected.text();
+ cls.push(selected.attr("class"));
+ return $("<span/>", {"class": cls.join(' ')}).text(selected.text());
}
+ //TODO: apply the span as above to preserve the css-class of the original select
return selected.length ? selected.map( function() {
return $( this ).text();
}).get().join( ", " ) : self.placeholder;

0 comments on commit 7651fd9

Please sign in to comment.