我的子菜单导航中需要Bootstrap popover。当我打开菜单时它正常工作,弹出窗口还有一个关闭按钮,但再次打开它时它不起作用。这意味着它可以处理奇怪的点击,甚至点击它都不起作用。
但是在Bootstrap 3.3.2中,它们都能正常工作
js
$(function () {
var popOverSettings = {
placement: 'bottom',
container: 'body',
html: true,
selector: '#change-customer',
title: '<a href="#" class="close" >×</a>',
content: function () {
return $('#customer-popover').html();
}
}
$('body').popover(popOverSettings).on('shown.bs.popover', function(){
enableTypeAhead();
});
$(document).on("click", ".popover .close" , function(){
$(this).parents(".popover").popover('hide');
});
});
&#13;
<nav class="navbar navbar-default" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li id="change-customer"><a href="#">Example 1</a></li>
<li id="ex2"><a href="#">Example 2</a></li>
<li id="ex3"><a href="#">Example 3</a></li>
<li id="ex5"><a href="#">Example 4</a></li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</nav>
<div class="col-md-8" id="customer-popover" style="display: none">
<input class="typeahead form-control inputbox-shadow" type="text" placeholder="Search Customer">
</div>
&#13;
工作版本:Codeply link
答案 0 :(得分:2)
销毁popover而不是隐藏它:
{{1}}