aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.autocomplete.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2012-11-28 10:33:44 -0500
committerScott González <scott.gonzalez@gmail.com>2012-11-28 10:33:59 -0500
commitdec844570fae5edf56876b760b9358fde2ecb5e7 (patch)
treef26cba55944b538152ffb7754cc697f76fe27432 /ui/jquery.ui.autocomplete.js
parente77edc60991dc0d9908e056aa05adc49b9daa7cd (diff)
downloadjquery-ui-dec844570fae5edf56876b760b9358fde2ecb5e7.tar.gz
jquery-ui-dec844570fae5edf56876b760b9358fde2ecb5e7.zip
Autocomplete: When appendTo is a jQuery object or a DOM element, don't search against the document. Fixes #8858 - Autocomplete: Fails when appendTo is detached from the DOM.
Diffstat (limited to 'ui/jquery.ui.autocomplete.js')
-rw-r--r--ui/jquery.ui.autocomplete.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js
index f2a7089c4..5edb84d44 100644
--- a/ui/jquery.ui.autocomplete.js
+++ b/ui/jquery.ui.autocomplete.js
@@ -181,7 +181,7 @@ $.widget( "ui.autocomplete", {
this._initSource();
this.menu = $( "<ul>" )
.addClass( "ui-autocomplete" )
- .appendTo( this.document.find( this.options.appendTo || "body" )[ 0 ] )
+ .appendTo( this._appendTo() )
.menu({
// custom key handling for now
input: $(),
@@ -320,6 +320,14 @@ $.widget( "ui.autocomplete", {
}
},
+ _appendTo: function() {
+ var element = this.options.appendTo;
+ if ( element && (element.jquery || element.nodeType) ) {
+ return $( element );
+ }
+ return this.document.find( element || "body" ).eq( 0 );
+ },
+
_isMultiLine: function() {
// Textareas are always multi-line
if ( this.element.is( "textarea" ) ) {