我怎样才能使 Twitter Bootstrap 弹出窗口始终打开?

How can I make Twitter Bootstrap Popover that always be open?

我想让 Twitter Bootstrap 弹出窗口在加载文档时永远打开。我看到了一些解决方案,但它们通过 clickhover!

显示弹出窗口

有我的代码:

$("#min-allowed-price .bar-label-shape").popover({
    offset: 10,
    trigger:'manual'
    });

I want to make Twitter Bootstrap Popover that when document loaded

$(document).ready(function() {
    $("button").popover("show");
});

be open for ever.

disabled 属性添加到按钮或 preventDefault() hide.bs.popover event

$('button').on('hide.bs.popover', function (e) {
  e.preventDefault();
});

jsfiddle

您实际上并没有触发弹出窗口。您可以通过调用 popover('show'):

$("#min-allowed-price .bar-label-shape").popover({
  offset: 10,
  trigger:'manual'
}).popover('show');

来自 Bootstrap 的 Popover documentation:

.popover('show')

Reveals an element's popover. Returns to the caller before the popover has actually been shown (i.e. before the shown.bs.popover event occurs). This is considered a "manual" triggering of the popover. Popovers whose both title and content are zero-length are never displayed.

$('#element').popover('show')

一种方法是手动显示弹出框,然后删除弹出框的点击事件处理程序 link。

$('.popover-visible-trigger')
    .popover('show')
    .off('click');

查看工作 jsfiddle

但问题是,也许您不需要这样做。如果您希望弹出窗口始终显示,为什么不将其添加到标记中?