0

qtipポップアップを呼び出した要素を取得したいと思います。ここのドキュメントでは、位置を設定できます。のようなjqueryセレクターを使用して位置を設定したい$(this).find('.icon')。問題はthis、qtip を呼び出した要素ではないことです (私はそれだと思いますwindow)。

それを呼び出したハンドルを取得する方法を知っている人はいますか (ターゲットを に設定した場合のように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 に答える