【问题标题】:make qtip disappear right away让qtip立即消失
【发布时间】:2011-06-26 04:13:02
【问题描述】:

所以我希望 qtip 有以下行为:

当我单击对象时应该显示 qtip(我可以正常工作)...但是我希望它在几毫秒后消失,而无需我做任何事情...。你会怎么做去配置qtip来做到这一点?

我试过了

hide: {
    when : 'inactive',
    delay : 100,
    fixed: false
}

但它不起作用....

任何帮助将不胜感激...谢谢

【问题讨论】:

    标签: javascript jquery events mouseover qtip


    【解决方案1】:

    如果您只希望工具提示在屏幕上闪烁:

    $(".tooltip").qtip({
        content: "Test tooltip",
        api: {
            // As soon as the qtip is fully visible..
            onShow: function (event) {
                // Keep a reference to the qtip..
                that = this;
                // After 1ms (to let things settle down)
                setTimeout(function () {
                    // Hide the qtip
                    that.hide();
                }, 1); // change this value to have it stay on screen longer
            }
        },
        show: "mouseover"
    });
    

    【讨论】:

    • 应该是 $(that).hide();
    【解决方案2】:

    我认为您的代码是正确的,但 delay 引起了问题。 100 毫秒只有 0.1 秒,所以可能 qtip 需要比那个时间更长的时间来渲染,当它被告知隐藏自己时它还不存在(只是一个猜测)。

    我会增加延迟(您可能希望您的用户在几秒钟内看到提示),看看是否有帮助。下面是一个使用 1000 毫秒的示例:http://jsfiddle.net/andrewwhitaker/dVEYq/

    【讨论】:

      【解决方案3】:

      我知道这是一个老问题,但以防万一有人路过,在 qTip2 中正确的做法是:(事件而不是 api)

      events: {
                  show: function(event, api){
                      var that = this;
                      setTimeout(function () {
                         // Hide the qtip
                          that.hide();
                      }, 3000); // change this value to have it stay on screen longer
                  }
              }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-05-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-12-06
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多