1
0
mirror of synced 2024-11-26 06:46:04 +03:00

prevent duplicate queries

This commit is contained in:
Igor Vaynberg 2013-03-14 12:47:46 -07:00
parent 3be8547584
commit 9acfc6faa5

View File

@ -1349,7 +1349,17 @@ the specific language governing permissions and limitations under the Apache Lic
*/
// abstract
updateResults: function (initial) {
var search = this.search, results = this.results, opts = this.opts, data, self=this, input;
var search = this.search,
results = this.results,
opts = this.opts,
data,
self = this,
input,
term = search.val(),
lastTerm=$.data(this.container, "select2-last-term");
// prevent duplicate queries against the same term
if (initial !== true && lastTerm && equal(term, lastTerm)) return;
// if the search is currently hidden we do not alter the results
if (initial !== true && (this.showSearchInput === false || !this.opened())) {
@ -1408,6 +1418,8 @@ the specific language governing permissions and limitations under the Apache Lic
this.resultsPage = 1;
$.data(this.container, "select2-last-term", term);
opts.query({
element: opts.element,
term: search.val(),