]> source.dussan.org Git - jquery-ui.git/commitdiff
Autocomplete: Handle detached elements for appendTo after create.
authorScott González <scott.gonzalez@gmail.com>
Fri, 7 Dec 2012 16:58:58 +0000 (11:58 -0500)
committerScott González <scott.gonzalez@gmail.com>
Fri, 7 Dec 2012 16:58:58 +0000 (11:58 -0500)
tests/unit/autocomplete/autocomplete_options.js
ui/jquery.ui.autocomplete.js

index d3a25d2fc8c01818d79a74ed7af93ac6ea8d7b94..913f5bc2893d1a02b05e436338060fe04be8bb94 100644 (file)
@@ -5,7 +5,7 @@ module( "autocomplete: options" );
 var data = [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl" ];
 
 test( "appendTo", function() {
-       expect( 7 );
+       expect( 8 );
        var detached = $( "<div>" ),
                element = $( "#autocomplete" ).autocomplete();
        equal( element.autocomplete( "widget" ).parent()[0], document.body, "defaults to body" );
@@ -39,6 +39,10 @@ test( "appendTo", function() {
        });
        equal( element.autocomplete( "widget" ).parent()[0], detached[0], "detached DOM element" );
        element.autocomplete( "destroy" );
+
+       element.autocomplete().autocomplete( "option", "appendTo", detached );
+       equal( element.autocomplete( "widget" ).parent()[0], detached[0], "detached DOM element via option()" );
+       element.autocomplete( "destroy" );
 });
 
 function autoFocusTest( afValue, focusedLength ) {
index c049b856953814329c185d97e7c20e0020d6f019..a858b3382987b7b88ea00b812ecee9c47d376803 100644 (file)
@@ -314,7 +314,7 @@ $.widget( "ui.autocomplete", {
                        this._initSource();
                }
                if ( key === "appendTo" ) {
-                       this.menu.element.appendTo( this.document.find( value || "body" )[0] );
+                       this.menu.element.appendTo( this._appendTo() );
                }
                if ( key === "disabled" && value && this.xhr ) {
                        this.xhr.abort();