本文介绍了使用引导弹出式回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在使用引导程序弹出窗口向表单添加一些其他字段。要设置选择框的格式,我需要利用popover回调,但是似乎无法启动该回调。如果您更喜欢使用jsfiddle,请感谢您的任何建议。
I'm currently using bootstrap popovers to add some additional fields to my form. To format my select boxes, I need to take advantage of the popover callback, however I seem to be unable to get the callback to fire. If you prefer to use jsfiddle, check it out here. Thanks for any suggestions.
$("[data-toggle=popover]").popover({
html: true,
content: function() {
return $('#popover-content').html();
},
showCallback: function() {
alert('called back');
}
});
.container {
padding: 20px;
}
.form-control {
width: 120px;
}
.popover {
max-width: 400px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<h3>Bootstrap 3 Popover HTML Example</h3>
<ul class="list-unstyled">
<li><a data-placement="bottom" data-toggle="popover" data-container="body" data-placement="left" type="button" data-html="true" href="#" id="login"><span class="glyphicon glyphicon-search" style="margin:3px 0 0 0"></span></a>
</li>
<div id="popover-content" class="hide">
<form class="form-inline" role="form">
<div class="form-group">
<h1>My content</h1>
</div>
</form>
</div>
</ul>
</div>
推荐答案
没有弹出选项 showCallback
,而是尝试使用
There is no popover option showCallback
instead try using one of Bootstraps built in popover events
例如,当显示弹出窗口时触发警报,您可以这样做
So for example triggering the alert when the popover is shown you would do this
$("[data-toggle=popover]").on('shown.bs.popover', function () {
alert('called back');
});
我更新了您的为例...
I updated your JS Fiddle for an example...
这篇关于使用引导弹出式回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!