diff options
-rw-r--r-- | tests/visual/tooltip/tooltip.html | 21 | ||||
-rw-r--r-- | ui/jquery.ui.tooltip.js | 21 |
2 files changed, 29 insertions, 13 deletions
diff --git a/tests/visual/tooltip/tooltip.html b/tests/visual/tooltip/tooltip.html index 022093bc7..7b931b155 100644 --- a/tests/visual/tooltip/tooltip.html +++ b/tests/visual/tooltip/tooltip.html @@ -44,6 +44,24 @@ return "Loading..."; } }); + // asynchronous content with caching + var content; + $("#ajax2").tooltip({ + content: function(response) { + if (content) { + return content; + } + $.ajax({ + url: "ajaxcontent.php", + cache: false, + success: function(result) { + content = result; + response(result); + } + }); + return "Loading..."; + } + }); // custom position $("#right2").tooltip({ @@ -117,6 +135,9 @@ <div id="ajax" style="width: 100px;" class="ui-widget-content" title="never be seen"> gets its content via ajax </div> + <div id="ajax2" style="width: 100px;" class="ui-widget-content" title="never be seen"> + gets its content via ajax, caches the response + </div> <div id="context2" class="ui-widget ui-widget-content"> <span title="something" style="border:1px solid blue">span</span> diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 32d5afeee..8341131ca 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -82,9 +82,12 @@ $.widget("ui.tooltip", { this.current = target; this.currentTitle = target.attr("title"); var content = this.options.content.call(target[0], function(response) { - // ignore async responses that come in after the tooltip is already hidden - if (self.current == target) - self._show(event, target, response); + // IE may instantly serve a cached response, need to give it a chance to finish with _show before that + setTimeout(function() { + // ignore async responses that come in after the tooltip is already hidden + if (self.current == target) + self._show(event, target, response); + }, 13); }); if (content) { self._show(event, target, content); @@ -111,10 +114,7 @@ $.widget("ui.tooltip", { this.tooltip.attr("aria-hidden", "false"); target.attr("aria-describedby", this.tooltip.attr("id")); - if (this.tooltip.is(":animated")) - this.tooltip.stop().show().fadeTo("normal", this.opacity); - else - this.tooltip.is(':visible') ? this.tooltip.fadeTo("normal", this.opacity) : this.tooltip.fadeIn(); + this.tooltip.stop(false, true).fadeIn(); this._trigger( "open", event ); }, @@ -132,12 +132,7 @@ $.widget("ui.tooltip", { current.removeAttr("aria-describedby"); this.tooltip.attr("aria-hidden", "true"); - if (this.tooltip.is(':animated')) - this.tooltip.stop().fadeTo("normal", 0, function() { - $(this).hide().css("opacity", ""); - }); - else - this.tooltip.stop().fadeOut(); + this.tooltip.stop(false, true).fadeOut(); this._trigger( "close", event ); } |