是否可以通过函数调用显示qtip?

Auf*_*gel 3 qtip

我目前正在尝试创建一个文本选择脚本,以便人们可以标记文本,然后将其插入到表单中.

因此,我想显示一个带有"发送到表单"链接的弹出窗口,但是我在创建一个带有qtip的工具提示时遇到了问题(我在我的网站上的任何地方都使用它)从我的脚本中找出文本是否已被标记(如果我的脚本无法复制任何内容,则不会有链接).

我正在使用此脚本进行选择检测:http://mark.koli.ch/2009/09/use-javascript-and-jquery-to-get-user-selected-text.html

如果当前有一个a alert,则稍后将调用qtip:

Kolich.Selector.mouseup = function(){
    var st = Kolich.Selector.getSelected();
    if(st!=''){
        alert("You selected:\n"+st); // here will be showQTipAtMouseButtonFixed()
    }
}
Run Code Online (Sandbox Code Playgroud)

现在问题似乎是整个qtip都集中在悬停上.我当然可以围绕.qtip()调用包装一个函数,但这并没有真正解决问题.然后工具提示将附加到我的功能,并且只有当我悬停它所连接的元素仍然显示.

这将是包装函数的qtip

function showQTipAtMouseButtonFixed() {
    $('#content').qtip({
        content: 'Hello!',
        position: {
            target: 'mouse',
            adjust: { mouse: false }
        },
        hide: {
            fixed: true
        },
        style: {
            tip: true,
            classes: 'ui-tooltip-red'
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

使用this而不是"#content"(我在相关帖子中看到)也不起作用.

但是我希望它在背景中始终处于活动状态,并在Kolich.Selector说"现在你被显示了!"时显示.

我还show: 'click' 通过Google找到了一个提示,但这也不是解决方案.它只适用于您真正假设点击的情况,但在我的情况下,它更像是双击或鼠标移动或键盘.

这可能与qtip或我必须display从头开始使用CSS 吗?

Pat*_*ick 6

你试过qtip的"show"功能吗?

function showQTipAtMouseButtonFixed()
{
   $('#target').qtip({
       // your options

       show: '',
       hide: '',

       content: {
            prerender: true, // important
            text: 'Whatever you want to display'
       }
   }).qtip('show');
}
Run Code Online (Sandbox Code Playgroud)