Quellcode durchsuchen

ignore replies that come in after select2 has been closed. fixes #299

Igor Vaynberg vor 12 Jahren
Ursprung
Commit
e4fbf91915
1 geänderte Dateien mit 7 neuen und 0 gelöschten Zeilen
  1. 7 0
      select2.js

+ 7 - 0
select2.js

@@ -1129,6 +1129,10 @@
                         matcher: this.opts.matcher,
                         callback: this.bind(function (data) {
 
+                    // ignore a response if the select2 has been closed before it was received
+                    if (!self.opened()) return;
+
+
                     self.opts.populateResults.call(this, results, data.results, {term: term, page: page, context:context});
 
                     if (data.more===true) {
@@ -1206,6 +1210,9 @@
                     callback: this.bind(function (data) {
                 var def; // default choice
 
+                // ignore a response if the select2 has been closed before it was received
+                if (!this.opened()) return;
+
                 // save context, if any
                 this.context = (data.context===undefined) ? null : data.context;