【问题标题】:Destroy bootstrap-popover after mousedown event is completedmousedown 事件完成后销毁 bootstrap-popover
【发布时间】:2014-10-12 01:34:07
【问题描述】:

我想在mousedown 事件完成时销毁特定的弹出框。只要用户按下鼠标,弹出框就可见。当用户不再存在时,应该有 3.5 秒的延迟,然后它应该被销毁。

只要mousedown 为真,我当前的实现就可以正确显示弹出框,但是当我释放鼠标时,弹出框立即被销毁,没有延迟。我该怎么办?

jQuery:

function destroyPopover(selector)
{
    setTimeout(function () {
        $(selector).popover('destroy');
        }, 3500);
}   

...

$('#otp_table').on('mousedown', 'td', function() {
        $(this).popover({
                container: 'body',
                content: 'Lorem ipsum',
                placement: 'top',
            }).popover('show');
    }, hidePopover(this));

【问题讨论】:

    标签: javascript jquery twitter-bootstrap popover


    【解决方案1】:

    为了纠正我的问题,我在 popover 对象中添加了这一行:

    delay: { "hide": 3500 },
    

    这给了...

    $('#otp_table').on('mousedown', 'td', function() {
        $(this).popover({
                container: 'body',
                delay: { "hide": 3500 },
                content: 'Lorem ipsum',
                placement: 'top',
            }).popover('show');
    }, destroyPopover(this);
    

    另外,我已经删除了我的 destroyPopover() 函数中的 setInterval,它给出了这个...

    function destroyPopover(selector)
    {
        $(selector).popover('destroy');
    }
    

    希望对你有用!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-23
      相关资源
      最近更新 更多