获取名为 qTip 的元素



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

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

谢谢。

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

这是我提出的解决方案,它似乎有效。如果我修改了 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/

最新更新