use opts.id func to check for id instead of hardcoded id key
This commit is contained in:
parent
45442aa8d7
commit
95b89d44f8
@ -536,7 +536,7 @@
|
|||||||
containerCssClass: "",
|
containerCssClass: "",
|
||||||
dropdownCssClass: "",
|
dropdownCssClass: "",
|
||||||
populateResults: function(container, results, query) {
|
populateResults: function(container, results, query) {
|
||||||
var uidToData={}, populate, markup=[], uid, data, result, children, formatted;
|
var uidToData={}, populate, markup=[], uid, data, result, children, formatted, id=this.opts.id;
|
||||||
|
|
||||||
populate=function(results, depth) {
|
populate=function(results, depth) {
|
||||||
|
|
||||||
@ -544,7 +544,7 @@
|
|||||||
for (i = 0, l = results.length; i < l; i = i + 1) {
|
for (i = 0, l = results.length; i < l; i = i + 1) {
|
||||||
|
|
||||||
result=results[i];
|
result=results[i];
|
||||||
selectable=("id" in result); // TODO switch to id() function
|
selectable=id(result) !== undefined;
|
||||||
compound=("children" in result) && result.children.length > 0;
|
compound=("children" in result) && result.children.length > 0;
|
||||||
|
|
||||||
markup.push("<li class='select2-result-depth-"+depth);
|
markup.push("<li class='select2-result-depth-"+depth);
|
||||||
@ -878,7 +878,7 @@
|
|||||||
matcher: this.opts.matcher,
|
matcher: this.opts.matcher,
|
||||||
callback: this.bind(function (data) {
|
callback: this.bind(function (data) {
|
||||||
|
|
||||||
self.opts.populateResults(results, data.results, {term: term, page: page, context:context});
|
self.opts.populateResults.call(this, results, data.results, {term: term, page: page, context:context});
|
||||||
|
|
||||||
if (data.more===true) {
|
if (data.more===true) {
|
||||||
more.detach();
|
more.detach();
|
||||||
@ -952,7 +952,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
results.empty();
|
results.empty();
|
||||||
self.opts.populateResults(results, data.results, {term: search.val(), page: this.resultsPage, context:null});
|
self.opts.populateResults.call(this, results, data.results, {term: search.val(), page: this.resultsPage, context:null});
|
||||||
postRender();
|
postRender();
|
||||||
|
|
||||||
if (data.more === true) {
|
if (data.more === true) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user