mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Autocomplete: Append to closest .ui-front if available.
This commit is contained in:
parent
2c1643509a
commit
80e46c93a8
@ -1,6 +1,6 @@
|
|||||||
TestHelpers.commonWidgetTests( "autocomplete", {
|
TestHelpers.commonWidgetTests( "autocomplete", {
|
||||||
defaults: {
|
defaults: {
|
||||||
appendTo: "body",
|
appendTo: null,
|
||||||
autoFocus: false,
|
autoFocus: false,
|
||||||
delay: 300,
|
delay: 300,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
|
@ -18,11 +18,11 @@ test( "appendTo", function() {
|
|||||||
equal( $( "#ac-wrap2 .ui-autocomplete" ).length, 0, "only appends to one element" );
|
equal( $( "#ac-wrap2 .ui-autocomplete" ).length, 0, "only appends to one element" );
|
||||||
element.autocomplete( "destroy" );
|
element.autocomplete( "destroy" );
|
||||||
|
|
||||||
element.autocomplete({
|
$( "#ac-wrap2" ).addClass( "ui-front" );
|
||||||
appendTo: null
|
element.autocomplete();
|
||||||
});
|
equal( element.autocomplete( "widget" ).parent()[0], $( "#ac-wrap2" )[0], "null, inside .ui-front" );
|
||||||
equal( element.autocomplete( "widget" ).parent()[0], document.body, "null" );
|
|
||||||
element.autocomplete( "destroy" );
|
element.autocomplete( "destroy" );
|
||||||
|
$( "#ac-wrap2" ).removeClass( "ui-front" );
|
||||||
|
|
||||||
element.autocomplete().autocomplete( "option", "appendTo", "#ac-wrap1" );
|
element.autocomplete().autocomplete( "option", "appendTo", "#ac-wrap1" );
|
||||||
equal( element.autocomplete( "widget" ).parent()[0], $( "#ac-wrap1" )[0], "modified after init" );
|
equal( element.autocomplete( "widget" ).parent()[0], $( "#ac-wrap1" )[0], "modified after init" );
|
||||||
|
20
ui/jquery.ui.autocomplete.js
vendored
20
ui/jquery.ui.autocomplete.js
vendored
@ -23,7 +23,7 @@ $.widget( "ui.autocomplete", {
|
|||||||
version: "@VERSION",
|
version: "@VERSION",
|
||||||
defaultElement: "<input>",
|
defaultElement: "<input>",
|
||||||
options: {
|
options: {
|
||||||
appendTo: "body",
|
appendTo: null,
|
||||||
autoFocus: false,
|
autoFocus: false,
|
||||||
delay: 300,
|
delay: 300,
|
||||||
minLength: 1,
|
minLength: 1,
|
||||||
@ -323,10 +323,22 @@ $.widget( "ui.autocomplete", {
|
|||||||
|
|
||||||
_appendTo: function() {
|
_appendTo: function() {
|
||||||
var element = this.options.appendTo;
|
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 );
|
||||||
}
|
}
|
||||||
return this.document.find( element || "body" ).eq( 0 );
|
|
||||||
|
if ( !element ) {
|
||||||
|
element = this.element.closest( ".ui-front" );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !element.length ) {
|
||||||
|
element = this.document[0].body;
|
||||||
|
}
|
||||||
|
|
||||||
|
return element;
|
||||||
},
|
},
|
||||||
|
|
||||||
_isMultiLine: function() {
|
_isMultiLine: function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user