Merge pull request #1320 from jamesramsay/selected-css-class
Added support for css class for selected elements
This commit is contained in:
commit
38f6b2bd71
14
select2.js
14
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("<div title='"+this.opts.escapeMarkup(formatted)+"'>"+this.opts.escapeMarkup(formatted)+"</div>");
|
||||
}
|
||||
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"); },
|
||||
|
Loading…
Reference in New Issue
Block a user