简体   繁体   English

在复选框上启用或禁用qtip

[英]Enable or disable qtip on checkbox

I use asp.net mvc razor code. 我使用asp.net mvc剃须刀代码。 I use qtip to give a show popup on mouseover. 我使用qtip在鼠标悬停时显示弹出窗口。 I have a checkbox in the settings page,which is used to enable/disable the qtip. 我在设置页面上有一个复选框,用于启用/禁用qtip。

Here is my code: 这是我的代码:

function tooltip(a) {
    Sapppid = document.getElementById("s" + a).textContent;
    Sapppid = Sapppid.replace("s", "");
    $.ajax({
        url: window.location.pathname + "Scheduler/getappointmentdetails",
        type: "POST",
        data: { sharedappid: Sapppid }
    })
    .success(function (result) {
        document.getElementById('ApptDetails').value = result;
    });

    $("#" + a).qtip({
        overwrite: false,
        content: {
            text: "...",
            button: 'Close',
            ajax: {
                url: window.location.pathname + "Scheduler/Eventdetails/" + Sapppid,
                type: 'Post',
                success: function (result) {} 
            } 
        },
        style: {
            classes: '',
            width: 500
        },
        position: {
            my: 'right bottom center',
            at: 'middle right center',
            target: $("#" + a)
        },
        show: {
            ready: true,
            solo: true
        },
        hide: {
            when: { event: 'mouseout unfocus' }, fixed: true, delay: 200
        }
    });   
}

I design qtip to showup on a dynamic content. 我设计了qtip来显示动态内容。 I use qtip2. 我用qtip2。 I din't find any documentation to disable or enable in the site. 我在网站上找不到任何要禁用或启用的文档。

This is the only code i found, but couldnt figure out where to apply this.: 这是我找到的唯一代码,但是无法弄清楚该在哪里应用。

http://qtip2.com/api#api.disable http://qtip2.com/api#api.disable

api.disable(true);

// Enable it again
api.disable(false);

attach an onclick event to your checkbox and place the disable within the qtip function on the element you're targetting 将onclick事件附加到您的复选框,并将禁用功能放在您定位的元素的qtip函数中

Code Example: 代码示例:

$('.checkbox').on('click', function(){
    $('.dynamic').qtip('disable', true);
});

Give this a try and let me know if it works in the comments 试试看,让我知道它是否在评论中起作用

try something like this 尝试这样的事情

    $('.checkbox').on('click', function(){
        var api = $('.dynamic').qtip('api');
        api.disable(true);
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM