2012-08-23 51 views
11

我试图整合twitter bootstrap模式,但由于某种原因,它不起作用。Twitter Bootstrap 2.1 - Modal无法正常工作

问题是当页面加载时显示模态。

我在<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…</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> 

它呈现在页面加载后直接,如果我再次按下模式按钮,它就会消失,并出现第二次,但整个页面是darkend (即使是模态本身也是噩梦)

任何人都遇到同样的问题?

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

回答

14

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

+0

感谢这个固定:) –