0

我正在使用 jQuery UI 的工具提示,最终,我试图将工具提示重置回它的第一个初始状态。

由于似乎没有“重置”功能,知道如何实现这一点吗?

到目前为止,我已经尝试使用关闭回调函数,我可以重置工具提示,但是工具提示没有关闭。我在文档中找不到关于如何在使用关闭回调函数时关闭工具提示的任何内容。

jsFiddle 链接:http: //jsfiddle.net/Handyman/mJMD5/

var $selector = $('div.content div.rounded_corners'),
    $timeout;

$selector.tooltip({
    items: 'a.detail',
    content: $loader,
    open: function(event, ui)
    {
        // test this with a timeout to find out what will happen if I use AJAX to bring in the content
        $timeout = setTimeout(function()
        {
            // replaces the loading image with this text, but changes the content for all tooltips, which is undesirable
            $selector.tooltip('option', 'content', 'sometimes you just have to wait a second');
        }, 2000);
    },
    close: function()
    {
        // reset the content back to the loading image
        $selector.tooltip('option', 'content', $loader);
        clearTimeout($timeout);

        // adding return true doesn't have any effect on if the tooltip closes or not
        return true;
    }
});
4

1 回答 1

1

这是一个解决方案,您需要通过执行以下操作重新启动工具提示:

close: function()
{
    // reset the content back to the loading image
    $selector.tooltip('close').tooltip('destroy').attr('title','hello');     

    clearTimeout($timeout);
    fnAddToolTip(); 
    // adding return true doesn't have any effect on if the tooltip closes or not
    return true;
}

这是一个小提琴:http: //jsfiddle.net/dwaddell/87wV3/

这是添加到您的小提琴中的解决方案:http: //jsfiddle.net/dwaddell/mJMD5/1/

于 2013-05-15T20:04:21.560 回答