Autocomplete: Fixed handling of race conditions when using jQuery 1.3.2. Fixes #6904 - Autocomplete: Race condition handling means.

(cherry picked from commit a1ab9678e9)
This commit is contained in:
Scott González 2011-01-27 14:49:59 -05:00
parent e1174228c7
commit 6b9b513e77

View File

@ -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;
}
});
};