Skip to content

Commit 9acfc6f

Browse files
committed
prevent duplicate queries
1 parent 3be8547 commit 9acfc6f

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

select2.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,17 @@ the specific language governing permissions and limitations under the Apache Lic
13491349
*/
13501350
// abstract
13511351
updateResults: function (initial) {
1352-
var search = this.search, results = this.results, opts = this.opts, data, self=this, input;
1352+
var search = this.search,
1353+
results = this.results,
1354+
opts = this.opts,
1355+
data,
1356+
self = this,
1357+
input,
1358+
term = search.val(),
1359+
lastTerm=$.data(this.container, "select2-last-term");
1360+
1361+
// prevent duplicate queries against the same term
1362+
if (initial !== true && lastTerm && equal(term, lastTerm)) return;
13531363

13541364
// if the search is currently hidden we do not alter the results
13551365
if (initial !== true && (this.showSearchInput === false || !this.opened())) {
@@ -1408,6 +1418,8 @@ the specific language governing permissions and limitations under the Apache Lic
14081418

14091419
this.resultsPage = 1;
14101420

1421+
$.data(this.container, "select2-last-term", term);
1422+
14111423
opts.query({
14121424
element: opts.element,
14131425
term: search.val(),

0 commit comments

Comments
 (0)