@@ -2087,7 +2087,7 @@ the specific language governing permissions and limitations under the Apache Lic
20872087 // single
20882088 updateSelection : function ( data ) {
20892089
2090- var container = this . selection . find ( "span" ) , formatted ;
2090+ var container = this . selection . find ( "span" ) , formatted , cssClass ;
20912091
20922092 this . selection . data ( "select2-data" , data ) ;
20932093
@@ -2096,6 +2096,10 @@ the specific language governing permissions and limitations under the Apache Lic
20962096 if ( formatted !== undefined ) {
20972097 container . append ( this . opts . escapeMarkup ( formatted ) ) ;
20982098 }
2099+ cssClass = this . opts . formatSelectionCssClass ( data , container ) ;
2100+ if ( cssClass !== undefined ) {
2101+ container . addClass ( cssClass ) ;
2102+ }
20992103
21002104 this . selection . removeClass ( "select2-default" ) ;
21012105
@@ -2632,12 +2636,17 @@ the specific language governing permissions and limitations under the Apache Lic
26322636 var choice = enableChoice ? enabledItem : disabledItem ,
26332637 id = this . id ( data ) ,
26342638 val = this . getVal ( ) ,
2635- formatted ;
2639+ formatted ,
2640+ cssClass ;
26362641
26372642 formatted = this . opts . formatSelection ( data , choice . find ( "div" ) ) ;
26382643 if ( formatted != undefined ) {
26392644 choice . find ( "div" ) . replaceWith ( "<div title='" + this . opts . escapeMarkup ( formatted ) + "'>" + this . opts . escapeMarkup ( formatted ) + "</div>" ) ;
26402645 }
2646+ cssClass = this . opts . formatSelectionCssClass ( data , choice . find ( "div" ) ) ;
2647+ if ( cssClass != undefined ) {
2648+ choice . addClass ( cssClass ) ;
2649+ }
26412650
26422651 if ( enableChoice ) {
26432652 choice . find ( ".select2-search-choice-close" )
@@ -2988,6 +2997,7 @@ the specific language governing permissions and limitations under the Apache Lic
29882997 return results ;
29892998 } ,
29902999 formatResultCssClass : function ( data ) { return undefined ; } ,
3000+ formatSelectionCssClass : function ( data , container ) { return undefined ; } ,
29913001 formatNoMatches : function ( ) { return "No matches found" ; } ,
29923002 formatInputTooShort : function ( input , min ) { var n = min - input . length ; return "Please enter " + n + " more character" + ( n == 1 ? "" : "s" ) ; } ,
29933003 formatInputTooLong : function ( input , max ) { var n = input . length - max ; return "Please delete " + n + " character" + ( n == 1 ? "" : "s" ) ; } ,
0 commit comments