Add text function for formatResult and formatSelection
This commit is contained in:
parent
d487fc58a8
commit
b8ce36a65e
16
select2.js
16
select2.js
@ -459,6 +459,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
* the text.
|
* the text.
|
||||||
*/
|
*/
|
||||||
function local(options) {
|
function local(options) {
|
||||||
|
|
||||||
var data = options, // data elements
|
var data = options, // data elements
|
||||||
dataText,
|
dataText,
|
||||||
tmp,
|
tmp,
|
||||||
@ -3386,11 +3387,11 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
dropdownCssClass: "",
|
dropdownCssClass: "",
|
||||||
formatResult: function(result, container, query, escapeMarkup) {
|
formatResult: function(result, container, query, escapeMarkup) {
|
||||||
var markup=[];
|
var markup=[];
|
||||||
markMatch(result.text, query.term, markup, escapeMarkup);
|
markMatch(this.text(result), query.term, markup, escapeMarkup);
|
||||||
return markup.join("");
|
return markup.join("");
|
||||||
},
|
},
|
||||||
formatSelection: function (data, container, escapeMarkup) {
|
formatSelection: function (data, container, escapeMarkup) {
|
||||||
return data ? escapeMarkup(data.text) : undefined;
|
return data ? escapeMarkup(this.text(data)) : undefined;
|
||||||
},
|
},
|
||||||
sortResults: function (results, container, query) {
|
sortResults: function (results, container, query) {
|
||||||
return results;
|
return results;
|
||||||
@ -3409,6 +3410,17 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
maximumInputLength: null,
|
maximumInputLength: null,
|
||||||
maximumSelectionSize: 0,
|
maximumSelectionSize: 0,
|
||||||
id: function (e) { return e == undefined ? null : e.id; },
|
id: function (e) { return e == undefined ? null : e.id; },
|
||||||
|
text: function (e) {
|
||||||
|
if (e && this.data && this.data.text) {
|
||||||
|
if ($.isFunction(this.data.text)) {
|
||||||
|
return this.data.text(e);
|
||||||
|
} else {
|
||||||
|
return e[this.data.text];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return e.text;
|
||||||
|
}
|
||||||
|
},
|
||||||
matcher: function(term, text) {
|
matcher: function(term, text) {
|
||||||
return stripDiacritics(''+text).toUpperCase().indexOf(stripDiacritics(''+term).toUpperCase()) >= 0;
|
return stripDiacritics(''+text).toUpperCase().indexOf(stripDiacritics(''+term).toUpperCase()) >= 0;
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user