11

我试图集成 twitter 引导模式,但由于某种原因它不起作用。

问题是模式在页面加载时显示。

我在我的<head>

   <script type="text/javascript">
    $('#myModal').modal({show: false,keyboard: false});
    </script>

但是没有效果。

我使用的代码:(http://twitter.github.com/bootstrap/javascript.html#modals

<-- Button to trigger modal -->
<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>

<-- Modal -->
<div class="modal" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">Modal header</h3>
  </div>
  <div class="modal-body">
    <p>One fine body…&lt;/p>
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
    <button class="btn btn-primary">Save changes</button>
  </div>
</div>

它在页面加载后直接呈现,如果我再次按下模式按钮它会消失,并且第二次出现但整个页面都变暗(甚至模式本身也变暗了)

有人遇到过同样的问题吗?

我把它推到heroku,这样你就可以看到问题了。http://elobeast.com/ (右上角“启动演示模式”)

4

1 回答 1

14

您需要将该类添加.hide到模态框的主容器中以隐藏它,直到它被调用。

于 2012-08-23T22:59:05.087 回答