diff --git a/select2.js b/select2.js index 6fb443e9..5822094d 100644 --- a/select2.js +++ b/select2.js @@ -2087,7 +2087,7 @@ the specific language governing permissions and limitations under the Apache Lic // single updateSelection: function (data) { - var container=this.selection.find("span"), formatted; + var container=this.selection.find("span"), formatted, cssClass; this.selection.data("select2-data", data); @@ -2096,6 +2096,10 @@ the specific language governing permissions and limitations under the Apache Lic if (formatted !== undefined) { container.append(this.opts.escapeMarkup(formatted)); } + cssClass=this.opts.formatSelectionCssClass(data, container); + if (cssClass !== undefined) { + container.addClass(cssClass); + } this.selection.removeClass("select2-default"); @@ -2632,12 +2636,17 @@ the specific language governing permissions and limitations under the Apache Lic var choice = enableChoice ? enabledItem : disabledItem, id = this.id(data), val = this.getVal(), - formatted; + formatted, + cssClass; formatted=this.opts.formatSelection(data, choice.find("div")); if (formatted != undefined) { choice.find("div").replaceWith("
"+this.opts.escapeMarkup(formatted)+"
"); } + cssClass=this.opts.formatSelectionCssClass(data, choice.find("div")); + if (cssClass != undefined) { + choice.addClass(cssClass); + } if(enableChoice){ choice.find(".select2-search-choice-close") @@ -2988,6 +2997,7 @@ the specific language governing permissions and limitations under the Apache Lic return results; }, formatResultCssClass: function(data) {return undefined;}, + formatSelectionCssClass: function(data, container) {return undefined;}, formatNoMatches: function () { return "No matches found"; }, formatInputTooShort: function (input, min) { var n = min - input.length; return "Please enter " + n + " more character" + (n == 1? "" : "s"); }, formatInputTooLong: function (input, max) { var n = input.length - max; return "Please delete " + n + " character" + (n == 1? "" : "s"); },