现在我知道以前有人问过它,但我似乎无法让 JQUERY 对话框工作。
我有一个从 JQUERY 网站获得的简单示例,但对话框从未弹出。
我的 _Layout.cshtml 页面
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title - My ASP.NET MVC Application</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width" />
<script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.20.min.js")" type="text/javascript"></script>
<link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
<header>
<div class="content-wrapper">
<div class="float-left">
<p class="site-title">@Html.ActionLink("your logo here", "Index", "Home")</p>
</div>
<div class="float-right">
<section id="login">
@Html.Partial("_LoginPartial")
</section>
<nav>
<ul id="menu">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("About", "About", "Home")</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
</ul>
</nav>
</div>
</div>
</header>
<div id="body">
@RenderSection("featured", required: false)
<section class="content-wrapper main-content clear-fix">
@RenderBody()
</section>
</div>
<footer>
<div class="content-wrapper">
<div class="float-left">
<p>© @DateTime.Now.Year - My ASP.NET MVC Application</p>
</div>
</div>
</footer>
@Scripts.Render("~/bundles/jquery")
@RenderSection("scripts", required: false)
</body>
</html>
我的 Index.cshtml 页面
<div id="dialog" title="Basic dialog">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
<script type="text/javascript">
$(function () {
alert("HELLO");
});
</script>
<script type="text/javascript">
$(function () {
$("#dialog").dialog();
});
</script>
警报弹出,但对话框没有,知道为什么吗?
编辑:做了一些编辑,现在我有了这个。
<div id="dialog" title="Basic dialog">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
<script type="text/javascript">
$(function () {
alert("HELLO");
});
</script>
<script type="text/javascript">
$(function () {
alert("HELLO2");
});
</script>
<script type="text/javascript">
$(function () {
$("#dialog").dialog();
});
</script>
<script type="text/javascript">
$(function () {
alert("HELLO3");
});
</script>
现在,当我有三个警报时,它会发出 HELLO 和 HELLO2 警报,但它永远不会发出 HELLO3 .. 但是,如果我将 HELLO3 脚本放在对话框脚本之上,它将显示所有 3 个警报。有什么想法吗?