Skip to content
Permalink
Browse files
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 18, 2010
1 parent d2a12ff commit 2aabc3911c3f9e4ca2bbb48d298ee6e5648b4c12
Showing with 8 additions and 1 deletion.
  1. +8 −1 ui/jquery.ui.autocomplete.js
@@ -26,6 +26,9 @@ $.widget( "ui.autocomplete", {
},
source: null
},

pending: 0,

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

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

this.source( { term: value }, this.response );
@@ -304,7 +308,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 ) {

0 comments on commit 2aabc39

Please sign in to comment.