小编she*_*nyl的帖子

Twitter Bootstrap模态窗口闪烁

我想使用Ajax在模态窗口中插入一些东西,所以我尝试手动打开模态窗口.代码看起来像这样

    $(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;
        });
    });
Run Code Online (Sandbox Code Playgroud)

HTML直接从bootstrap 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>
Run Code Online (Sandbox Code Playgroud)

所以问题是第一次点击按钮似乎工作正常,在第二次点击模式窗口显示1秒左右然后消失.如果我将"切换"更改为"显示",则在第二次单击后,背景将不会完全淡出.我该怎么调试呢?

jquery modal-dialog twitter-bootstrap

11
推荐指数
1
解决办法
9770
查看次数

标签 统计

jquery ×1

modal-dialog ×1

twitter-bootstrap ×1