我只希望在单击某个按钮时显示模态。
目前,每当我加载页面时,模态都会显示出来。
有人可以告诉我我要去哪里严重错误吗?
<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>
<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>
我正在使用 ASP.NET MVC 3
编辑:我只有以下作为Javascript:
<script>
$('#myModal').on('show', function() {
});
</script>
这些是我对 CSS 和 JS 的引用:
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title</title>
<script src=@Url.Content("https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js") type="text/javascript"> </script>
<script src=@Url.Content("../../Content/lib/bootstrap/js/bootstrap.min.js") type="text/javascript"></script>
<link href=@Url.Content("/Content/lib/bootstrap/css/bootstrap.min.css") rel="stylesheet" type="text/css" />
<link href=@Url.Content("/Content/lib/bootstrap/css/bootstrap-responsive.min.css") rel="stylesheet" type="text/css" />
<link href=@Url.Content("../../Content/lib/bootstrap/css/bootstrap-combobox.css") rel="stylesheet" type="text/css" />
</head>