diff --git a/select2.js b/select2.js index ca8b974c..8d295c7b 100644 --- a/select2.js +++ b/select2.js @@ -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(),