我想使用Ajax在模式窗口中插入内容,所以我尝试手动打开模式窗口。代码如下所示Twitter Bootstrap模式窗口闪烁
$(function(){
$('#modal-from-dom').modal({
backdrop: true,
keyboard: true
});
$('#modalbutton').click(function(){
$('#my-modal').bind('show', function() {
// do sth with the modal
});
$('#modal-from-dom').modal('toggle');
return false;
});
});
的HTML被直接从引导JS网页
<div id="modal-from-dom" class="modal hide fade">
<div class="modal-header">
<a href="#" class="close">×</a>
<h3>Modal Heading</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<a href="#" class="btn primary">Primary</a>
<a href="#" class="btn secondary">Secondary</a>
</div>
</div>
<button id="modalbutton" class="btn">Launch Modal</button>
复制所以问题是点击在第一时间似乎工作就好了按钮,之后的第二点击模式窗口显示1秒左右,然后消失。如果我将“切换”更改为“显示”,在第二次点击之后,背景将不会完全淡出。我怎样才能调试呢?
是'.modal()'一个某种形式的插件?什么是'#我的模态',你在做什么?可能的问题是,您每次点击都会绑定“show”事件,并且它会执行一些操作,将您的开关拧紧。 –
该问题已关闭。我已经更新了问题中的代码。 – shenyl
请发布您的解决方案。 – JSuar