bootstrap-popover - 如何从 Bootstrap 中的弹出窗口获取弹出窗口

标签 bootstrap-popover

我尝试了下面的代码,但我没有收到第二个弹出窗口,我的方法似乎有一些问题,我不知道如何获得第二个弹出窗口...

$(function() {
    $(".pendingList, .pendings").popover();
 });
.icon3{
	background: url('http://blog.flattr.net/wp-content/uploads/2011/09/stackoverflow.png') 1px 1px no-repeat;
	background-position: center;
	height:100px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>

<div class="icon3 pendingList" data-toggle="popover" data-trigger="click" data-html="true" data-placement="bottom" 
													data-content="<a href='#' class='pendings' data-toggle='popover' data-trigger='click' data-html='true' data-placement='bottom' 
												data-content='test' >Pending(5)</a>"></div>

最佳答案

您的代码不起作用,因为执行 popover 方法时元素不存在。尝试下面的代码,效果很好!

$(function() {
    $(".pendingList").popover();
    $('.pendingList').on('inserted.bs.popover', function () {
      $(".pendings").popover();
    });
 });
.icon3{
	background: url('http://blog.flattr.net/wp-content/uploads/2011/09/stackoverflow.png') 1px 1px no-repeat;
	background-position: center;
	height:100px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>

<div class="icon3 pendingList" data-toggle="popover" data-trigger="click" data-html="true" data-placement="bottom" data-content="<a href='#' class='pendings' data-toggle='popover' data-trigger='click' data-html='true' data-placement='bottom' data-content='test' >Pending(5)</a>"></div>

关于bootstrap-popover - 如何从 Bootstrap 中的弹出窗口获取弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39182560/

相关文章:

vuejs2 - 以编程方式添加 Bootstrap 弹出窗口 vue-full-calendar

jquery - 如何更改 Bootstrap 弹出窗口箭头边框颜色而不填充它?

jquery - 如何使用 jQuery 使用 bootstrap 5 popover?

jquery - 如何使用 Bootstrap 4.3 在 Popover 中包含表单?

javascript - 如果目标元素被删除,带有 "body"容器集的 Bootstrap 弹出窗口不会删除弹出窗口

c# - 如何使用 C# 代码填充引导模式?

jquery - 将引导弹出窗口输入值绑定(bind)到拥有弹出窗口的元素

javascript - 如何显示无效输入的 Bootstrap 弹出窗口?

html - 如何修复 Bootstrap slider 上的弹出位置?

javascript - 如何在动态元素上绑定(bind) bootstrap popover