From 6e2b484d7f484d6cc6300a41eb9f6bd532c68915 Mon Sep 17 00:00:00 2001 From: Lotte-Sara Laan Date: Mon, 16 Jun 2014 16:27:27 +0200 Subject: [PATCH] Fix problems with content async ajax request There were 2 problems, first af all, the check for "ui-tooltip-open" was done -before- the _delay call. This means that when the _open function was actually called, the user could have already moved his mouse out. I've moved the check to the start of the _open function because I believe that's where it should actually always be checked. Second, the mouseout events were only set in the _open function. This way, with the async ajax request, the mouseout events were never called when the tooltip wasn't actually opened (the user moved the mouse away before the content was able to update). I've set the events in the open function now as well. --- ui/tooltip.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/ui/tooltip.js b/ui/tooltip.js index 52be04dcb91..4ad2c354e7a 100644 --- a/ui/tooltip.js +++ b/ui/tooltip.js @@ -192,6 +192,17 @@ return $.widget( "ui.tooltip", { } }); } + + // Set mouseover events so we can actually call close even before the _open function is called + // This is needed voor async ajax requests + var events = {}; + if ( !event || event.type === "mouseover" ) { + events.mouseleave = "close"; + } + if ( !event || event.type === "focusin" ) { + events.focusout = "close"; + } + this._on( true, target, events ); this._updateContent( target, event ); }, @@ -207,10 +218,6 @@ return $.widget( "ui.tooltip", { } content = contentOption.call( target[0], function( response ) { - // ignore async response if tooltip was closed already - if ( !target.data( "ui-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 that._delay(function() { @@ -231,6 +238,11 @@ return $.widget( "ui.tooltip", { }, _open: function( event, target, content ) { + // ignore async response if tooltip was closed already + if ( !target.data( "ui-tooltip-open" ) ) { + return; + } + var tooltip, events, delayedShow, a11yContent, positionOption = $.extend( {}, this.options.position );