]> source.dussan.org Git - jquery-ui.git/commitdiff
Tooltip: Follow the standard appendTo logic
authorScott González <scott.gonzalez@gmail.com>
Mon, 23 Mar 2015 23:09:50 +0000 (19:09 -0400)
committerScott González <scott.gonzalez@gmail.com>
Thu, 9 Jun 2016 17:19:31 +0000 (13:19 -0400)
Even though there's no reason to ever configure the parent element via an
`appendTo` option, following the standard logic is useful for scrollable
elements and native dialogs.

Fixes #10739
Closes gh-1517

(cherry picked from commit 8cf98798a58afb7197bce0d6ca1c5b658ae04011)

ui/tooltip.js

index 8408f6781fb86490fdc72de0ec67c093bc6e51ec..23446ae654b33630bf05c2258b514e7a26a2590a 100644 (file)
@@ -424,7 +424,7 @@ return $.widget( "ui.tooltip", {
                        .addClass( "ui-tooltip-content" )
                        .appendTo( tooltip );
 
-               tooltip.appendTo( this.document[0].body );
+               tooltip.appendTo( this._appendTo( element ) );
 
                return this.tooltips[ id ] = {
                        element: element,
@@ -442,6 +442,16 @@ return $.widget( "ui.tooltip", {
                delete this.tooltips[ tooltip.attr( "id" ) ];
        },
 
+       _appendTo: function( target ) {
+               var element = target.closest( ".ui-front, dialog" );
+
+               if ( !element.length ) {
+                       element = this.document[ 0 ].body;
+               }
+
+               return element;
+       },
+
        _destroy: function() {
                var that = this;