1

我有一个提示,设置为粘性并在单击链接时打开。我还在线索提示上设置了一个关闭按钮,所有这些都很好用。如果除了当前的关闭按钮之外,有人在提示提示之外单击,我想关闭提示提示。我正在寻找悬停解决方案,只需在提示提示之外单击即可。

4

4 回答 4

3

我是这样做的:

    onShow: function() {
        // close cluetip when users click outside of it
        $(document).click(function(e) {
            var isInClueTip = $(e.target).closest('#cluetip');
            if (isInClueTip.length === 0) {
                $('.cluetip-default').hide();
            }
        })
    },
于 2011-10-19T17:49:08.047 回答
2

根据FAQ,有一个API方法可以让你触发关闭:

线索提示 1.0.3 的新内容:如何以编程方式关闭(隐藏)线索提示?如果要触发一个线索提示关闭,基于其他一些交互,可以使用如下代码:$(document).trigger('hideCluetip');

所以我认为你可以做这样的事情:


$('#myCluetip').cluetip({
  onShow: function() {
    $(document).one('mousedown',function() {
      $(document).trigger('hideCluetip');
    })
  });
});

这通过将 mousedown 事件的一次性事件处理程序绑定到文档正文来工作,然后触发 Cluetip 人员所说的将隐藏打开的 Cluetips 的事件。使用一次性事件处理程序意味着您不会在每次有人单击某物时发送 hideCluetip 触发器。

于 2011-04-12T21:33:37.973 回答
2

斯托尼的解决方案对我不起作用。

我使用了@Gary Green 的解决方案,它工作正常 - 但这仍然不是我想要的确切的“关闭鼠标悬停/悬停”解决方案。

最后,我发现 Cluetip 本身提供了一种方法来做到这一点。

只需设置值 "mouseOutClose: false" ,如下所示:

$("#myForm :input").cluetip(
    {
        sticky: true, 
        closePosition: 'title', 
        arrows: true,
        mouseOutClose: true
    }
);
于 2011-05-06T06:43:18.480 回答
0

查看您的代码会有所帮助,但无论如何您都可以按照这些思路做一些事情;

$(document).click(function(e) {
    if (!$(e.target).hasClass('cluetip'))
    {
      // Close the cluetip here.  
    }
});
于 2011-04-12T20:59:32.940 回答