【发布时间】:2013-12-10 22:51:15
【问题描述】:
我想在我的 MVC4 应用程序中使用 JQueryUI,但我没有看到我想要的效果。 我将向您展示代码,我认为这是初学者的错误。我一定忘记了一个指令。
_Layout.cshtml(只是声明)
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8" />
<title>@ViewBag.Title - Mon application ASP.NET MVC</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width" />
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryui")
@RenderSection("JavaScript", required: false)
@Styles.Render("~/Content/css")
myView.cshtml
@section JavaScript
{
<script type="text/javascript">
$(function () {
$("#dialog").dialog({
autoOpen: false,
show: {
effect: "blind",
duration: 1000
},
hide: {
effect: "explode",
duration: 1000
}
});
$("#opener").click(function () {
$("#dialog").dialog("open");
});
});
</script>
}
@{
ViewBag.Title = "Home Page";
}
@{
if (!Session.IsNewSession && Session.Contents["connecte"].Equals(true))
{
<div id="dialog" title="Basic dialog">
<p>This is an animated dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
<button id="opener">Open Dialog</button>
}
else
{
<div class="group_bannner_right">
<img src="~/Images/picture.png" width="550" height="316" alt="baner">
</div>
<header class="group_bannner_left">
<hgroup>
<h1>Simple.Think. </h1>
<h2>
“The little things are infinitely the most important.“
</h2>
</hgroup>
</header>
}
}
我有这个错误:
Uncaught TypeError: Object [object Object] has no method 'dialog'
(index):18 (anonymous function)
(index):18 fire
jquery-1.8.2.js:988 self.fireWith
jquery-1.8.2.js:1096 jQuery.extend.ready
jquery-1.8.2.js:420 DOMContentLoaded
【问题讨论】:
-
看起来不错,您是在编辑 Bundler 文件后构建的吗?和/或检查控制台错误是什么/是否有任何错误。
-
我没有编辑 Bundler 文件。
-
我只想这样做JQueryUI
-
检查浏览器开发工具中的 javascript 控制台和网络选项卡是否有错误。
-
我有这个与我的案例有关的错误:未捕获的 TypeError: Object [object Object] has no method 'dialog' (index):18 (anonymous function) (index):18 fire jquery-1.8 .2.js:988 self.fireWith jquery-1.8.2.js:1096 jQuery.extend.ready jquery-1.8.2.js:420 DOMContentLoaded
标签: jquery asp.net jquery-ui asp.net-mvc-4