Bootstrap模式popover隐藏关闭
问题描述:
我有一个模式,当试图运行将激活验证popover。我在3秒后添加了一个超时弹窗来隐藏。但是如果关闭模式,超时功能似乎停止,弹出不会隐藏,甚至直接告诉它隐藏不起作用。Bootstrap模式popover隐藏关闭
HTML模式
<div class="modal hide fade" id ="password_modal">
<div class="modal-header">
<h3>Change Password <span class="extra-title muted"></span></h3>
</div>
<div class="modal-body form-horizontal">
<div class="control-group">
<label for="current_password" class="control-label">Current Password</label>
<div class="controls">
<input type="password" name="current_password">
</div>
</div>
<div class="control-group">
<label for="new_password" class="control-label">New Password</label>
<div class="controls">
<input type="password" name="new_password">
</div>
</div>
<div class="control-group">
<label for="confirm_password" class="control-label">Confirm Password</label>
<div class="controls">
<input type="password" name="confirm_password">
</div>
</div>
</div>
<div class="modal-footer">
<button href="#" class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button href="#" class="btn btn-primary" id="password_modal_save">Save changes</button>
</div>
</div>
里面的模式
options = {
content: raw_data.errors,
html: true,
placement: 'top',
trigger: 'manual'
}
$('#password_modal_save').popover(options);
$('#password_modal_save').popover('show');
setTimeout(function(){ click.popover('hide'); }, 3000);
模态接近听众
$("body").on("hidden", "#password_modal", function(event){
$(this).remove(); //Remove the modal to stop duplications
$('#password_modal_save').popover('hide'); //Targetting the popover directly
$('.popover').remove(); //Last solution to actually hiding it
});
我霍皮NG藏身比$('.popover').remove();
小提琴以外的酥料饼的清洁方法:http://jsfiddle.net/La2yn/20/
答
使用2.1.0有与模态时关闭没有隐瞒酥料饼的错误。更新2.3.1,该酥料饼是现在关闭模式以及-.-
添加以下代码,以阻止事件冒泡和关闭模式以及
$("body").on("hidden", "#password_modal_save", function(e){
e.stopPropagation(); //Once popover is hidden stop the event from going to parent
});
您可以发布您的html .. – PSL 2013-05-01 00:18:56
已经添加了模态的HTML – Bankzilla 2013-05-01 01:12:40
你可以做一个小提琴http://jsfiddle.net/La2yn/。可能更新你的标记打开模式。 – PSL 2013-05-01 01:26:53