Skip to content

Commit

Permalink
ignore replies that come in after select2 has been closed. fixes #299
Browse files Browse the repository at this point in the history
  • Loading branch information
ivaynberg committed Aug 17, 2012
1 parent afd3537 commit e4fbf91
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit e4fbf91

Please sign in to comment.