页面加载时显示的 Bootstrap 停止模式
[英] Bootstrap stop Modal showing on page load
本文介绍了页面加载时显示的 Bootstrap 停止模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只希望在单击某个按钮时显示模态.
目前,每当我加载页面时,Modal 都会显示出来.
谁能告诉我我哪里出错了?
<a href="#myModal" role="button" class="btn" data-toggle="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">模态标头</h3>
<div class="modal-body"><p>一个精致的身体……</p>
<div class="modal-footer"><button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button><button class="btn btn-primary">保存更改</button>
我使用的是 ASP.NET MVC 3
我只有以下 Javascript:
<脚本>$('#myModal').on('show', function() {});
这些是我对 CSS 和 JS 的引用:
<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 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"/>头部>
解决方案
要使模态工作,您应该包括:
Bootstrap 使用模态中的自定义属性来查找和应用 javascript 功能.您不需要自己编写绑定.
I only want the Modal to show when I click on a certain button.
At the moment, the Modal shows itself whenever I load the page.
Can someone please tell me where I am going horribly wrong?
<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>
I am using ASP.NET MVC 3
EDIT: I only have the following as the Javascript:
<script>
$('#myModal').on('show', function() {
});
</script>
These are my references to CSS and 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>
解决方案
To get the modal to work you should include:
Bootstrap uses the custom attributes in the modal to find and apply the javascript functionality. You do not need to write the binding yourself.
这篇关于页面加载时显示的 Bootstrap 停止模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!