mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Autocomplete: Don't handle remote data if it's not the most recent request. Fixes #5982 - Autocomplete: Race condition causes incorrect suggestions.
This commit is contained in:
parent
1cca969c3c
commit
f115b48d2b
9
ui/jquery.ui.autocomplete.js
vendored
9
ui/jquery.ui.autocomplete.js
vendored
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user