equal( $( "#ac-wrap2 .ui-autocomplete" ).length, 0, "only appends to one element" );
element.autocomplete( "destroy" );
- element.autocomplete({
- appendTo: null
- });
- equal( element.autocomplete( "widget" ).parent()[0], document.body, "null" );
+ $( "#ac-wrap2" ).addClass( "ui-front" );
+ element.autocomplete();
+ equal( element.autocomplete( "widget" ).parent()[0], $( "#ac-wrap2" )[0], "null, inside .ui-front" );
element.autocomplete( "destroy" );
+ $( "#ac-wrap2" ).removeClass( "ui-front" );
element.autocomplete().autocomplete( "option", "appendTo", "#ac-wrap1" );
equal( element.autocomplete( "widget" ).parent()[0], $( "#ac-wrap1" )[0], "modified after init" );
version: "@VERSION",
defaultElement: "<input>",
options: {
- appendTo: "body",
+ appendTo: null,
autoFocus: false,
delay: 300,
minLength: 1,
_appendTo: function() {
var element = this.options.appendTo;
- if ( element && (element.jquery || element.nodeType) ) {
- return $( element );
+
+ if ( element ) {
+ element = element.jquery || element.nodeType ?
+ $( element ) :
+ this.document.find( element ).eq( 0 );
+ }
+
+ if ( !element ) {
+ element = this.element.closest( ".ui-front" );
}
- return this.document.find( element || "body" ).eq( 0 );
+
+ if ( !element.length ) {
+ element = this.document[0].body;
+ }
+
+ return element;
},
_isMultiLine: function() {