From 0d0c86210c4a6473888089ddcea918df8c156022 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 17 Dec 2010 10:48:17 -0500 Subject: [PATCH] Autocomplete: Abort pending ajax requests when disabled and prevent handling results when disabled. Fixes #6752 - Menu may still render when autocomplete is disabled. --- ui/jquery.ui.autocomplete.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 9b1b3f2c9..090dd7355 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -227,6 +227,9 @@ $.widget( "ui.autocomplete", { if ( key === "appendTo" ) { this.menu.element.appendTo( $( value || "body", this.element[0].ownerDocument )[0] ) } + if ( key === "disabled" && value && this.xhr ) { + this.xhr.abort(); + } }, _initSource: function() { @@ -241,7 +244,7 @@ $.widget( "ui.autocomplete", { } else if ( typeof this.options.source === "string" ) { url = this.options.source; this.source = function( request, response ) { - if (self.xhr) { + if ( self.xhr ) { self.xhr.abort(); } self.xhr = $.ajax({ @@ -292,7 +295,7 @@ $.widget( "ui.autocomplete", { }, _response: function( content ) { - if ( content && content.length ) { + if ( !this.options.disabled && content && content.length ) { content = this._normalize( content ); this._suggest( content ); this._trigger( "open" ); -- 2.39.5