【问题标题】:qTip positioning within a tooltip工具提示中的 qTip 定位
【发布时间】:2012-01-17 19:05:18
【问题描述】:

所以我让 qTip2 成功工作,将工具提示显示为一些 ajax 内容的模式。一切都很好,除了模式工具提示中的内容有链接,也调用另一个工具提示。当我点击其中任何一个时,定位会远离屏幕(如 -234.5px 和 -300px)。

我知道它与位置参数有关,但我无法让它工作。我可以让它使用之前点击的工具提示的目标作为它的位置吗?或者有没有办法在同一个工具提示中加载新的 ajax 内容?

主页链接:

<a class="qtipajaxmodal" id="[id here]" href="[link here]" 
    rel="[ajax link here]">Main Link</a>

ajax 拉取内容中的链接:

<a class="qtipajaxmodal" id="[id here]" href="[link here]" 
    rel="[ajax link to somewhere else here]">Another Link</a>

q提示代码:

// Make sure to only match links to wikipedia with a rel tag
       $('a.qtipajaxmodal').live('mouseover', function() {
           // Make sure to only apply one tooltip per element!
            if( $(this).data('qtip') === 'object' ){ return; } 

          $(this).qtip({
            id: 'modal2', 
            content: {

            text: '<div class="ajaxqtipmodal-load" alt="Loading..."></div>',
                ajax: {
                   url: $(this).attr('rel') 
                },
                title: {
                   text: 'Title: - ' + $(this).text(), 
                   button: true
                }
             },
              events: {
                 show: function(event, api) {
                     // Grab the tooltip element from the API
                     var tooltip = api.elements.tooltip
                     // ...and here's the extra event binds
                     tooltip.find('.ui-tooltip-titlebar').show();
                  },
                  hide: function(event, api) { 
                    //api.destroy(); 
                  }
               },
             position: {
                 target: $('#main'),
                 container: $('#main'),
                 my: 'center', // ...at the center of the viewport
                 at: 'center',
                 //viewport: $('#container'),
                 effect: false
             },
             show: {
                event: 'click',
                solo: true, // Only show one tooltip at a time
                modal: true,
                effect: function(offset) {
                    $(this).show(400); // "this" refers to the tooltip
                } // ...and make it modal

             },
             hide: false,
             style: {
                classes: 'ui-tooltip-fd-movie'
             }
         }).click(function(event) { event.preventDefault(); });
       });[/code]

【问题讨论】:

    标签: jquery qtip2


    【解决方案1】:

    我遇到了类似的问题。我相信这是因为链接在加载时可见,所以 qTip 将位置从屏幕上移开。我会在 ajax 内容加载后将 qTip 应用于新链接。

    编辑:

    尝试在第一个 qTip 的 show 事件上添加 qTip:

    show: function(event, api) {
        $(".qtipajaxmodal").qTip(...);
    }
    

    【讨论】:

    • 你的意思是链接在加载时不可见?新链接是从第一个 qtip 的 ajax 调用生成的。加载新内容后如何应用它?给它一个不同的类?感谢您的帮助!
    • 跟show中的solo属性有关。设置为 true 时,与当前 qTip 链接的 qtip 无法正确计算位置。当独奏关闭时,它似乎工作。每次我需要从 qtip 中拉出 qtip 时,上述编辑不会要求我嵌套一个 show 函数吗?有没有办法只将内容放在当前的 qTip 中?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多