aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.autocomplete.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2013-05-28 11:04:29 -0400
committerScott González <scott.gonzalez@gmail.com>2013-05-28 11:04:42 -0400
commit9e00e00f3b54770faa0291d6ee6fc1dcbad028cb (patch)
tree8256875c6531a011b8435bba40b4381b5b75b968 /ui/jquery.ui.autocomplete.js
parentd65cc9350fa205a46031a9b9b95cf04d98394036 (diff)
downloadjquery-ui-9e00e00f3b54770faa0291d6ee6fc1dcbad028cb.tar.gz
jquery-ui-9e00e00f3b54770faa0291d6ee6fc1dcbad028cb.zip
Autocomplete: Scope race condition handling to the instance. Fixes #9334 - Autocomplete: Multiple instances should be able to start asynchronous requests simultaneously.
Diffstat (limited to 'ui/jquery.ui.autocomplete.js')
-rw-r--r--ui/jquery.ui.autocomplete.js29
1 files changed, 13 insertions, 16 deletions
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js
index 6a3e8661d..8328cb6e5 100644
--- a/ui/jquery.ui.autocomplete.js
+++ b/ui/jquery.ui.autocomplete.js
@@ -41,6 +41,7 @@ $.widget( "ui.autocomplete", {
select: null
},
+ requestIndex: 0,
pending: 0,
_create: function() {
@@ -414,24 +415,20 @@ $.widget( "ui.autocomplete", {
this.source( { term: value }, this._response() );
},
- _response: (function() {
- var requestIndex = 0;
+ _response: function() {
+ var index = ++this.requestIndex;
- return function() {
- var index = ++requestIndex;
-
- return $.proxy(function( content ) {
- if ( index === requestIndex ) {
- this.__response( content );
- }
+ return $.proxy(function( content ) {
+ if ( index === this.requestIndex ) {
+ this.__response( content );
+ }
- this.pending--;
- if ( !this.pending ) {
- this.element.removeClass( "ui-autocomplete-loading" );
- }
- }, this );
- };
- })(),
+ this.pending--;
+ if ( !this.pending ) {
+ this.element.removeClass( "ui-autocomplete-loading" );
+ }
+ }, this );
+ },
__response: function( content ) {
if ( content ) {