]> source.dussan.org Git - jquery-ui.git/commitdiff
Autocomplete: Abort pending ajax requests when disabled and prevent handling results...
authorScott González <scott.gonzalez@gmail.com>
Fri, 17 Dec 2010 15:48:17 +0000 (10:48 -0500)
committerScott González <scott.gonzalez@gmail.com>
Sat, 18 Dec 2010 19:44:18 +0000 (14:44 -0500)
ui/jquery.ui.autocomplete.js

index 95e22103510e7629909869b0bc1ce542d5dd4702..84d76ec0849bcb83b85b2056efad23298da9abf8 100644 (file)
@@ -229,6 +229,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() {
@@ -243,7 +246,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({
@@ -294,7 +297,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" );