2012-05-28 9 views
7

私はモーダルクリックを閉じるために動作するモーダルデータ消去アクションを取得しようとしています。私が見つけられないという問題があるようで、うれしいことに、ここにいる誰かがそれに光を当てることができます。ここでは、コードTwitter Bootstrap Modal data-dismiss

<!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> 

がある私は、アクションをテストするため<div class="alert alert-block">に入れて、ブートストラップ・modal.js

を含むブートストラップの完全なスイートには、警告ではなく、モーダルで動作しているようです!

+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

「Show」はデフォルトで設定されているので、2つの#myModal行は同じことをする必要があります。 – Dirk

関連する問題