【问题标题】:Get element that called qTip?获取名为 qTip 的元素?
【发布时间】:2012-05-19 22:01:33
【问题描述】:

我想获取调用 qtip 弹出窗口的元素。在文档here 中,它允许您设置位置。我想使用像$(this).find('.icon') 这样的jquery 选择器来设置位置。问题是this 不是调用qtip 的元素(我认为它是window)。

有谁知道我如何获得调用它的句柄(就像我将目标设置为 false 一样)?

谢谢。

在 qtip 源代码中我发现了这个: if(config.position.target === false) config.position.target = $(this);

【问题讨论】:

  • 还有更多信息吗?我们需要更多您的实际代码,而不是任何文档中的代码。
  • 我现在有一个解决方案,但必须等待 6 个小时才能发布。我明天发。

标签: javascript jquery html object qtip


【解决方案1】:

这是我想出的解决方案,它似乎有效。如果我修改了 qtip 脚本,可能有更好的方法,但我想不管它。

$(".report-error").qtip(
{
    content: 'test content',
    position:
    {
        adjust:
        {
            screen: true
        },
        target: false, //it is changed in the 'beforeRender' part in api section. by leaving it as false here in the qtip it will set it as the position I need using $(this)
        corner:
        {
            target: 'bottomMiddle',
            tooltip: 'topRight'
        }
    },
    show:
    {
        when:
        {
            event: 'click'    
        }
    },
    style:
    { 
        name: 'cream',
        tip:
        {
            corner: 'topRight'
        },
        padding: 0,
        width: 400,
        border:
        {
            radius: 5,
            width: 0
        }
    },
    hide:
    {
        when:
        {
            event: 'unfocus'
        }
    },
    api:
    {
        beforeRender: function() { //get the position that qtip found with $(this) in it's script and change it using that as the start position

            this.options.position.target = $(this.elements.target).find('.icon');
            this.elements.target = this.options.position.target; //update this as well. I don't actually know what it's use is
        }
    }
});

它现在在http://wncba.co.uk/results/网站上运行

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-05
    • 2011-03-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多