aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-01-27 14:49:59 -0500
committerScott González <scott.gonzalez@gmail.com>2011-01-27 14:49:59 -0500
commita1ab9678e9bba6b20989104040bc31b782094335 (patch)
tree742952f642d8789d2b79ecb5a5b4dc2f40dfa1bd /ui
parent7a6dd71f8cf04d19c938f0678c0f2a2586ed65c5 (diff)
downloadjquery-ui-a1ab9678e9bba6b20989104040bc31b782094335.tar.gz
jquery-ui-a1ab9678e9bba6b20989104040bc31b782094335.zip
Autocomplete: Fixed handling of race conditions when using jQuery 1.3.2. Fixes #6904 - Autocomplete: Race condition handling means.
Diffstat (limited to 'ui')
-rw-r--r--ui/jquery.ui.autocomplete.js14
1 files changed, 8 insertions, 6 deletions
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js
index e62ea93fe..594d59530 100644
--- a/ui/jquery.ui.autocomplete.js
+++ b/ui/jquery.ui.autocomplete.js
@@ -15,6 +15,9 @@
*/
(function( $, undefined ) {
+// used to prevent race conditions with remote data sources
+var requestIndex = 0;
+
$.widget( "ui.autocomplete", {
defaultElement: "<input>",
options: {
@@ -257,17 +260,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;
}
});
};