【问题标题】:Is it possible to show a qtip with a function call?是否可以通过函数调用显示 qtip?
【发布时间】:2012-03-02 14:36:18
【问题描述】:

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

因此,我想显示一个带有“发送到表单”链接的弹出窗口,但是我在从我的脚本中使用 qtip(我在我的网站上随处使用)创建工具提示时遇到问题,该脚本会查明是否有文本标记与否(如果我的脚本无法复制任何内容,则不应有链接)。

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

目前有alert的地方,稍后会调用一个qtip:

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

现在问题似乎是整个 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'
        }
    });
}

使用this 代替"#content"(我在相关帖子中看到)也不起作用。

但我希望它始终在后台处于活动状态,并在 Kolich.Selector 说“现在您已显示!”时显示。

我还在show: 'click'via Google 上找到了提示,但这也不是解决方案。它仅在您真正假设单击时才有效,但在我的情况下,它是双击或鼠标移动或键盘。

这可以通过 qtip 实现还是我必须从头开始使用 CSS display?

【问题讨论】:

    标签: qtip


    【解决方案1】:

    你试过qtip的“show”功能吗?

    function showQTipAtMouseButtonFixed()
    {
       $('#target').qtip({
           // your options
    
           show: '',
           hide: '',
    
           content: {
                prerender: true, // important
                text: 'Whatever you want to display'
           }
       }).qtip('show');
    }
    

    【讨论】:

    • 谢谢@patrick....添加预渲染后:真的,qtip 工作!它实际上是做什么的??
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-24
    • 2016-02-26
    • 2016-09-08
    • 1970-01-01
    • 1970-01-01
    • 2019-11-10
    • 1970-01-01
    相关资源
    最近更新 更多