我有一个模式,在尝试运行时会激活一个弹出框进行验证。我已经在弹出窗口中添加了一个超时以在 3 秒后隐藏。但是,如果您关闭模式,超时功能似乎会停止,弹出框不会隐藏,甚至直接告诉它隐藏也不起作用。
模态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
});
我希望有一种更干净的方法来隐藏弹出框,而不是$('.popover').remove();
小提琴:http: //jsfiddle.net/La2yn/20/