diff options
author | Scott González <scott.gonzalez@gmail.com> | 2011-01-27 14:49:59 -0500 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2011-01-27 14:50:40 -0500 |
commit | 6b9b513e77deebe33bf8c81268a587c1f022556f (patch) | |
tree | 7a9f67b7a8d5e083917d2ff9c6cab68c826b48e2 | |
parent | e1174228c728854f972a3eeeb72fe8540debabea (diff) | |
download | jquery-ui-6b9b513e77deebe33bf8c81268a587c1f022556f.tar.gz jquery-ui-6b9b513e77deebe33bf8c81268a587c1f022556f.zip |
Autocomplete: Fixed handling of race conditions when using jQuery 1.3.2. Fixes #6904 - Autocomplete: Race condition handling means.
(cherry picked from commit a1ab9678e9bba6b20989104040bc31b782094335)
-rw-r--r-- | ui/jquery.ui.autocomplete.js | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 2ab3bfda9..a497b72fd 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -14,6 +14,9 @@ */ (function( $, undefined ) { +// used to prevent race conditions with remote data sources +var requestIndex = 0; + $.widget( "ui.autocomplete", { options: { appendTo: "body", @@ -256,17 +259,16 @@ $.widget( "ui.autocomplete", { url: url, data: request, dataType: "json", - success: function( data, status, xhr ) { - if ( xhr === self.xhr ) { + autocompleteRequest: ++requestIndex, + success: function( data, status ) { + if ( this.autocompleteRequest === requestIndex ) { response( data ); } - self.xhr = null; }, - error: function( xhr ) { - if ( xhr === self.xhr ) { + error: function() { + if ( this.autocompleteRequest === requestIndex ) { response( [] ); } - self.xhr = null; } }); }; |