2012-05-28 41 views
7

我正在尝试获取模态数据关闭操作以关闭点击模式。似乎有一个我找不到文件的问题,希望有人能在这里提供一些信息。下面是代码Twitter Bootstrap模式数据关闭

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset='UTF-8'/> 
    <title> Modal test </title> 
    <link href='themes/default/bootstrap/css/bootstrap.css' rel='stylesheet'/> 
    <link href='themes/default/bootstrap/css/bootstrap-responsive.css'  rel="stylesheet"/> 
</head> 
<body> 
<div class="modal" id="myModal"> 
    <div class="modal-header"> 
    <button class="close" data-dismiss="modal">×</button> 
    <h3>Modal header</h3> 
    </div> 
    <div class="modal-body"> 
    <p>One fine body…</p> 
    </div> 
    <div class="modal-footer"> 
    <a href="#" class="btn">Close</a> 
    <a href="#" class="btn btn-primary">Save changes</a> 
    </div> 
</div> 
<div class="alert alert-block"> 
    <a class="close" data-dismiss="alert" href="#">x</a> 
    <h4 class="alert-heading">Warning!</h4> 
    Best check yo self, you're not... 
</div> 

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
<script src="themes/default/bootstrap/js/bootstrap.js"></script> 
</body> 
</html> 

被引导的完整套件,包括自举modal.js

我放在<div class="alert alert-block">用于测试的动作,似乎在提醒工作,但不是模式!

+1

你调用$( “#myModal”)模式( '秀')功能?这里有一个工作小提琴你的例子:http://jsfiddle.net/tPv7u/ –

回答

2

添加此代码,请:

<script type="text/javascript"> 
    $(document).ready(function() { 
     $('#myModal').modal(); // initialized with defaults 
     $('#myModal').modal('show'); // open your modal dialog 
    }); 
</script> 
+1

'显示'是默认设置,所以这两个#myModal行应该做同样的事情。 – Dirk