Skip to content

Commit 0d0c862

Browse files
committed
Autocomplete: Abort pending ajax requests when disabled and prevent handling results when disabled. Fixes #6752 - Menu may still render when autocomplete is disabled.
1 parent cf48a3c commit 0d0c862

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ui/jquery.ui.autocomplete.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ $.widget( "ui.autocomplete", {
227227
if ( key === "appendTo" ) {
228228
this.menu.element.appendTo( $( value || "body", this.element[0].ownerDocument )[0] )
229229
}
230+
if ( key === "disabled" && value && this.xhr ) {
231+
this.xhr.abort();
232+
}
230233
},
231234

232235
_initSource: function() {
@@ -241,7 +244,7 @@ $.widget( "ui.autocomplete", {
241244
} else if ( typeof this.options.source === "string" ) {
242245
url = this.options.source;
243246
this.source = function( request, response ) {
244-
if (self.xhr) {
247+
if ( self.xhr ) {
245248
self.xhr.abort();
246249
}
247250
self.xhr = $.ajax({
@@ -292,7 +295,7 @@ $.widget( "ui.autocomplete", {
292295
},
293296

294297
_response: function( content ) {
295-
if ( content && content.length ) {
298+
if ( !this.options.disabled && content && content.length ) {
296299
content = this._normalize( content );
297300
this._suggest( content );
298301
this._trigger( "open" );

0 commit comments

Comments
 (0)