aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.autocomplete.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2010-08-24 09:14:44 -0400
committerScott González <scott.gonzalez@gmail.com>2010-08-24 09:14:44 -0400
commitf115b48d2bd79aff1f65fb895d1ebc9517d82edc (patch)
tree30107f96b6f354110cf4de42d3dbb01ba77aa854 /ui/jquery.ui.autocomplete.js
parent1cca969c3cbf83f17f947a022a3b315e26add89f (diff)
downloadjquery-ui-f115b48d2bd79aff1f65fb895d1ebc9517d82edc.tar.gz
jquery-ui-f115b48d2bd79aff1f65fb895d1ebc9517d82edc.zip
Autocomplete: Don't handle remote data if it's not the most recent request. Fixes #5982 - Autocomplete: Race condition causes incorrect suggestions.
Diffstat (limited to 'ui/jquery.ui.autocomplete.js')
-rw-r--r--ui/jquery.ui.autocomplete.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js
index 940d41adf..6b19c4401 100644
--- a/ui/jquery.ui.autocomplete.js
+++ b/ui/jquery.ui.autocomplete.js
@@ -210,7 +210,8 @@ $.widget( "ui.autocomplete", {
},
_initSource: function() {
- var array,
+ var self = this,
+ array,
url;
if ( $.isArray(this.options.source) ) {
array = this.options.source;
@@ -220,7 +221,11 @@ $.widget( "ui.autocomplete", {
} else if ( typeof this.options.source === "string" ) {
url = this.options.source;
this.source = function( request, response ) {
- $.getJSON( url, request, response );
+ self.xhr = $.getJSON( url, request, function( data, status, xhr ) {
+ if ( xhr === self.xhr ) {
+ response.apply( this, arguments );
+ }
+ });
};
} else {
this.source = this.options.source;