mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Autocomplete: Track pending requests and only remove the loading class when the last request completes. Fixes #6761 - Autocomplete: Loading class removed when multiple Ajax requests occur.
This commit is contained in:
parent
0d0c86210c
commit
08422d69da
9
ui/jquery.ui.autocomplete.js
vendored
9
ui/jquery.ui.autocomplete.js
vendored
@ -26,6 +26,9 @@ $.widget( "ui.autocomplete", {
|
||||
},
|
||||
source: null
|
||||
},
|
||||
|
||||
pending: 0,
|
||||
|
||||
_create: function() {
|
||||
var self = this,
|
||||
doc = this.element[ 0 ].ownerDocument,
|
||||
@ -289,6 +292,7 @@ $.widget( "ui.autocomplete", {
|
||||
},
|
||||
|
||||
_search: function( value ) {
|
||||
this.pending++;
|
||||
this.element.addClass( "ui-autocomplete-loading" );
|
||||
|
||||
this.source( { term: value }, this.response );
|
||||
@ -302,7 +306,10 @@ $.widget( "ui.autocomplete", {
|
||||
} else {
|
||||
this.close();
|
||||
}
|
||||
this.element.removeClass( "ui-autocomplete-loading" );
|
||||
this.pending--;
|
||||
if ( !this.pending ) {
|
||||
this.element.removeClass( "ui-autocomplete-loading" );
|
||||
}
|
||||
},
|
||||
|
||||
close: function( event ) {
|
||||
|
Loading…
Reference in New Issue
Block a user