From 404539e6d367744ae6b94d4941810c7b8d4393c8 Mon Sep 17 00:00:00 2001 From: Francisco Facioni Date: Sun, 6 May 2012 10:37:51 -0300 Subject: [PATCH] Aborts the ajax call when a new is coming up --- select2.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/select2.js b/select2.js index 61f2fe6b..de45d4e6 100755 --- a/select2.js +++ b/select2.js @@ -212,6 +212,7 @@ See the License for the specific language governing permissions and limitations function ajax(options) { var timeout, // current scheduled but not yet executed request requestSequence = 0, // sequence used to drop out-of-order responses + handler = null, quietMillis = options.quietMillis || 100; return function (query) { @@ -224,7 +225,10 @@ See the License for the specific language governing permissions and limitations data = data.call(this, query.term, query.page); - transport.call(null, { + if( null !== handler){ + handler.abort(); + } + handler = transport.call(null, { url: options.url, dataType: options.dataType, data: data,