From d32a9e81ecb8a201c1737c3226a99c33ced451af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rn=20Zaefferer?= Date: Sun, 19 Feb 2012 21:29:41 +0100 Subject: [PATCH] Tooltip: Mark target to prevent async results showing a tooltip that was closed already --- ui/jquery.ui.tooltip.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 924ce412198..cb23e9a4dda 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -103,7 +103,13 @@ $.widget( "ui.tooltip", { target.data( "tooltip-title", target.attr( "title" ) ); } + target.data( "tooltip-open", true ); + content = this.options.content.call( target[0], function( response ) { + // ignore async response if tooltip was closed already + if ( !target.data( "tooltip-open" ) ) { + return; + } // IE may instantly serve a cached response for ajax requests // delay this call to _open so the other call to _open runs first setTimeout(function() { @@ -186,6 +192,7 @@ $.widget( "ui.tooltip", { delete that.tooltips[ this.id ]; }); + target.removeData( "tooltip-open" ); target.unbind( "mouseleave.tooltip blur.tooltip keyup.tooltip" ); this._trigger( "close", event, { tooltip: tooltip } );