0

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

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

谢谢。

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

4

1 回答 1

0

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

于 2012-05-20T08:54:54.913 回答