Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Autocomplete: Track pending requests and only remove the loading clas…
…s when the last request completes. Fixes #6761 - Autocomplete: Loading class removed when multiple Ajax requests occur.
  • Loading branch information
scottgonzalez committed Dec 17, 2010
1 parent 0d0c862 commit 08422d6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ui/jquery.ui.autocomplete.js
Expand Up @@ -26,6 +26,9 @@ $.widget( "ui.autocomplete", {
},
source: null
},

pending: 0,

_create: function() {
var self = this,
doc = this.element[ 0 ].ownerDocument,
Expand Down Expand Up @@ -289,6 +292,7 @@ $.widget( "ui.autocomplete", {
},

_search: function( value ) {
this.pending++;
this.element.addClass( "ui-autocomplete-loading" );

this.source( { term: value }, this.response );
Expand All @@ -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 ) {
Expand Down

0 comments on commit 08422d6

Please sign in to comment.