Skip to content

Commit e4fbf91

Browse files
committed
ignore replies that come in after select2 has been closed. fixes select2#299
1 parent afd3537 commit e4fbf91

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

select2.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,10 @@
11291129
matcher: this.opts.matcher,
11301130
callback: this.bind(function (data) {
11311131

1132+
// ignore a response if the select2 has been closed before it was received
1133+
if (!self.opened()) return;
1134+
1135+
11321136
self.opts.populateResults.call(this, results, data.results, {term: term, page: page, context:context});
11331137

11341138
if (data.more===true) {
@@ -1206,6 +1210,9 @@
12061210
callback: this.bind(function (data) {
12071211
var def; // default choice
12081212

1213+
// ignore a response if the select2 has been closed before it was received
1214+
if (!this.opened()) return;
1215+
12091216
// save context, if any
12101217
this.context = (data.context===undefined) ? null : data.context;
12111218

0 commit comments

Comments
 (0)