Twitter bootstrap 引导模式popover关闭时隐藏
我有一个模式,当试图运行时,将激活一个弹出验证。我给popover添加了一个超时,以便在3秒后隐藏。但是,如果你关闭模式,超时功能似乎停止了,popover不会隐藏,甚至直接告诉它隐藏也不起作用 模式htmlTwitter bootstrap 引导模式popover关闭时隐藏,twitter-bootstrap,modal-dialog,popover,Twitter Bootstrap,Modal Dialog,Popover,我有一个模式,当试图运行时,将激活一个弹出验证。我给popover添加了一个超时,以便在3秒后隐藏。但是,如果你关闭模式,超时功能似乎停止了,popover不会隐藏,甚至直接告诉它隐藏也不起作用 模式html <div class="modal hide fade" id ="password_modal"> <div class="modal-header"> <h3>Change Password <span class="e
<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,而不是$('.popover')。remove()代码>
Fiddle:使用2.1.0时,当modal关闭时,popover不隐藏有一个bug。更新到2.3.1后,popover现在也关闭了模式--
在下面的代码中添加了阻止事件冒泡并关闭模式
$("body").on("hidden", "#password_modal_save", function(e){
e.stopPropagation(); //Once popover is hidden stop the event from going to parent
});
你能发布你的html吗?你已经为你制作的小提琴添加了html。可能更新您的标记tat会打开模式。在发现问题的过程中添加了一个小提琴。我使用的是bootstrap 2.1.0,正如你在我发布的提琴中看到的,它一定是有问题的。当你制作小提琴时,它使用的是2.3.1,工作得很好。如果你把它作为答案贴出来,我会接受的,因为你帮我找到了:)出于某种原因,在bootstrap.2.3.1
doing。popover('hide')
似乎也隐藏了模态。在弹出超时时发生