【问题标题】:How to keep qtip fixed如何保持 qtip 固定
【发布时间】:2010-12-23 06:19:28
【问题描述】:

我正在为 jQuery 使用 qtip,并且我有以下代码

$('#content a[href]').qtip(
   {
      content: 'Some basic content for the tooltip', // Give it some content, in this case a simple string
       style: { 
      name: 'cream', // Inherit from preset style
      tip: 'topLeft'
      },
      show: {
            when: 'click', // Show it on click...
            solo: true // ...and hide all others when its shown
      },
      hide: {
          when : 'focusout',
          fixed: true
      }
   });

想要的效果是当我点击链接时提示应该显示并停留在那里,除非我点击页面的其他部分(因此是焦点输出),但同时如果我点击提示本身,我不希望它消失,这样我就可以在其中插入有趣的东西,因此固定:真......但即使我这样做,当我点击提示时它仍然会消失......我是什么做错了,还是有其他方法可以防止提示在我点击它时消失,但如果我点击页面的另一部分,它就会消失?

【问题讨论】:

    标签: javascript html jquery jquery-events qtip


    【解决方案1】:

    你需要使用unfocus事件:

    $('#content a[href]').qtip({
        content: 'Some basic content for the tooltip',
        // Give it some content, in this case a simple string
        style: {
            name: 'cream',
            // Inherit from preset style
            tip: 'topLeft'
        },
        show: {
            when: 'click',
            // Show it on click...
            solo: true // ...and hide all others when its shown
        },
        hide: {
             when: { event: 'unfocus' }
        }
    });
    

    工作演示:http://jsfiddle.net/andrewwhitaker/rep87/

    来自documentation

    当单击文档上的任何其他位置(工具提示本身除外)时,“unfocus”事件会隐藏工具提示。


    【讨论】:

    • hmm 有趣,当我在我的代码上执行此操作时,当我点击其他地方时,qtip 不会消失......只有当我点击链接两次时它才会消失......演示似乎有效....有什么想法吗?
    • @kamikaze_pilot:您使用的是什么版本的 qTip 和 jQuery?该演示使用 jQuery 1.4.4(尽管它似乎适用于除 1.4.2 之外的任何版本 >= 1.3.2)和最新版本的 qTip。有什么办法可以在小提琴中复制这个问题?如果不是,会不会是其他代码?
    • 是的,我使用的是 jquery 1.4.2,但我也在使用 jquery.qtip-1.0 修订版,据说可以在 1.4.2 上运行(并且大部分情况下都可以).. ...我会尝试更新 jquery 看看会发生什么
    • 是的...更新了 jquery 并使用了 qtip 的 rc3...它现在似乎可以工作...谢谢
    • @kamikaze_pilot:太棒了!很高兴能提供帮助。
    猜你喜欢
    • 2021-03-25
    • 1970-01-01
    • 2017-06-20
    • 2018-02-05
    • 1970-01-01
    • 1970-01-01
    • 2015-05-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多