diff options
author | Andrew Couch <acouch@bluewolf.com> | 2012-10-15 16:15:36 -0400 |
---|---|---|
committer | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-10-21 13:15:44 -0400 |
commit | 3b2d1e7736be99671af70aa3b775d67b917517e5 (patch) | |
tree | 470fd54aa9e2499c36964a53ba0875ef68499f8e /ui | |
parent | 6b48ef5eca67f389d7a58f3c8a263ceb82c8becb (diff) | |
download | jquery-ui-3b2d1e7736be99671af70aa3b775d67b917517e5.tar.gz jquery-ui-3b2d1e7736be99671af70aa3b775d67b917517e5.zip |
Tooltip: handle removal of elements with delegated tooltips. Fixed #8646 - Delegated tooltips don't close when the tooltipped element is removed
Diffstat (limited to 'ui')
-rw-r--r-- | ui/jquery.ui.tooltip.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index b56d939e8..1be56c7ea 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -207,6 +207,7 @@ $.widget( "ui.tooltip", { _open: function( event, target, content ) { var tooltip, positionOption, events; + if ( !content ) { return; } @@ -268,6 +269,9 @@ $.widget( "ui.tooltip", { fakeEvent.currentTarget = target[0]; this.close( fakeEvent, true ); } + }, + remove: function( event ) { + this._removeTooltip( tooltip ); } }; if ( !event || event.type === "mouseover" ) { @@ -299,12 +303,15 @@ $.widget( "ui.tooltip", { tooltip.stop( true ); this._hide( tooltip, this.options.hide, function() { - $( this ).remove(); - delete that.tooltips[ this.id ]; + that._removeTooltip( $( this ) ); }); target.removeData( "tooltip-open" ); this._off( target, "mouseleave focusout keyup" ); + // Remove 'remove' binding only on delegated targets + if ( target[0] !== this.element[0] ) { + this._off( target, "remove" ); + } this._off( this.document, "mousemove" ); if ( event && event.type === "mouseleave" ) { @@ -344,6 +351,11 @@ $.widget( "ui.tooltip", { return id ? $( "#" + id ) : $(); }, + _removeTooltip: function( tooltip ) { + tooltip.remove(); + delete this.tooltips[ tooltip.attr( "id" ) ]; + }, + _destroy: function() { var that = this; |