mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Autocomplete: Abort pending ajax requests when disabled and prevent handling results when disabled. Fixes #6752 - Menu may still render when autocomplete is disabled.
This commit is contained in:
parent
cf48a3c5c8
commit
0d0c86210c
7
ui/jquery.ui.autocomplete.js
vendored
7
ui/jquery.ui.autocomplete.js
vendored
@ -227,6 +227,9 @@ $.widget( "ui.autocomplete", {
|
|||||||
if ( key === "appendTo" ) {
|
if ( key === "appendTo" ) {
|
||||||
this.menu.element.appendTo( $( value || "body", this.element[0].ownerDocument )[0] )
|
this.menu.element.appendTo( $( value || "body", this.element[0].ownerDocument )[0] )
|
||||||
}
|
}
|
||||||
|
if ( key === "disabled" && value && this.xhr ) {
|
||||||
|
this.xhr.abort();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_initSource: function() {
|
_initSource: function() {
|
||||||
@ -241,7 +244,7 @@ $.widget( "ui.autocomplete", {
|
|||||||
} else if ( typeof this.options.source === "string" ) {
|
} else if ( typeof this.options.source === "string" ) {
|
||||||
url = this.options.source;
|
url = this.options.source;
|
||||||
this.source = function( request, response ) {
|
this.source = function( request, response ) {
|
||||||
if (self.xhr) {
|
if ( self.xhr ) {
|
||||||
self.xhr.abort();
|
self.xhr.abort();
|
||||||
}
|
}
|
||||||
self.xhr = $.ajax({
|
self.xhr = $.ajax({
|
||||||
@ -292,7 +295,7 @@ $.widget( "ui.autocomplete", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_response: function( content ) {
|
_response: function( content ) {
|
||||||
if ( content && content.length ) {
|
if ( !this.options.disabled && content && content.length ) {
|
||||||
content = this._normalize( content );
|
content = this._normalize( content );
|
||||||
this._suggest( content );
|
this._suggest( content );
|
||||||
this._trigger( "open" );
|
this._trigger( "open" );
|
||||||
|
Loading…
Reference in New Issue
Block a user