【问题标题】:How to stop bootstrap popover form from disappearing如何阻止引导弹出框消失
【发布时间】:2013-08-10 17:24:23
【问题描述】:

在Contain form within a bootstrap popover? 之后,我设法在我的引导导航栏中使用的弹出框内放置了一个表单。当我将鼠标悬停在链接上时,弹出窗口工作正常,但是当我尝试移动鼠标以到达弹出窗体时,它消失了!我该如何解决这个问题?

导航栏项目:

<li <? if($active == "change_password") echo "class=\"active\""?>>
<?php echo '<a href="#" id="popover">the popover link</a>' ?>
</li>
<li class="divider-vertical"></li>

这是 js:

$('li:contains("the popover link")').popover({ 
    html : true,
    title: function() {
        return $("#popover-head").html();
    },
    content: function() {
        return $("#popover-content").html();
    }
});

【问题讨论】:

  • 您是否考虑过使用模态?这似乎更适合您尝试做的事情getbootstrap.com/2.3.2/javascript.html#modals
  • 你有一些事件悬停,鼠标悬停,鼠标悬停...在元素上?
  • 这是个好主意 - 我会检查模式。谢谢 - 比尔

标签: jquery twitter-bootstrap


【解决方案1】:

您可能已经解决了这个问题,或者有一个解决方案,但我想分享我的解决方案,因为我需要同样的东西,而模态不是设计的最佳选择。这适用于 Bootstrap 2.x 和 3.x,并将通过点击事件保持切换行为。

$('li:contains("the popover link")').popover({
    html : true,
    title: function() {
        return $("#popover-head").html();
    },
    content: function() {
        return $("#popover-content").html();
    }
}).mouseenter(function () {
    if (!$(this).parent().find('.popover').length) {
        $(this).popover('show');
    }
});

Demo

【讨论】:

    猜你喜欢
    • 2018-12-02
    • 2023-03-21
    • 1970-01-01
    • 1970-01-01
    • 2020-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多