JQuery用户界面不是MVC 4个工作Scripts.Render后? [英] JQuery UI not working in MVC 4 after Scripts.Render?
问题描述
不知道问题在这里。我读过一些其他的解决方案,并试图利用他们,但似乎没有任何合作。所有我想要做的就是呈现一个datepicker。我已经很多次做到了,只是不知道如果我有一个大脑,因为故障我已经在紧缩时间过去几个星期,或者是什么。
Not sure what the problem is here. I've read some of the other solutions and tried to use them, but nothing seems to be working. All I want to do is render a datepicker. I've done it many times before, just not sure if I'm having a brain malfunction because I've been in "crunch" time for the last few weeks, or what.
- 我有最新的JQuery(1.9.1),最新的JQuery用户界面(1.10.2)。
-
我检查了BundleConfig,一切似乎很好:
- I have the latest JQuery (1.9.1), latest JQuery UI (1.10.2).
I've checked the BundleConfig, and all seems well:
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
"~/Scripts/jquery-ui-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.unobtrusive*",
"~/Scripts/jquery.validate*"));
// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));
bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
"~/Content/themes/base/jquery.ui.core.css",
"~/Content/themes/base/jquery.ui.resizable.css",
"~/Content/themes/base/jquery.ui.selectable.css",
"~/Content/themes/base/jquery.ui.accordion.css",
"~/Content/themes/base/jquery.ui.autocomplete.css",
"~/Content/themes/base/jquery.ui.button.css",
"~/Content/themes/base/jquery.ui.dialog.css",
"~/Content/themes/base/jquery.ui.slider.css",
"~/Content/themes/base/jquery.ui.tabs.css",
"~/Content/themes/base/jquery.ui.datepicker.css",
"~/Content/themes/base/jquery.ui.progressbar.css",
"~/Content/themes/base/jquery.ui.theme.css"));
我已经设置了_Layout.cshtml头:
I've set up _Layout.cshtml header:
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")
<script>
$(function () {
$("#datepicker").datepicker();
});
</script>
然后在体内添加了另一个Scripts.Render(〜/包/ jQuery的)。然而,当我添加了日期选择器,没有任何反应......我只是得到一个文本框。
And then added another Scripts.Render("~/bundles/jquery") in the body. Yet when I add the datepicker, nothing happens...I just get a textbox.
我也尝试:
- 手动添加脚本参考在头
- 添加在jQuery脚本引用作为jQuery用户界面演示提供(网址)
什么......我的意思是没有什么工作。我仔细检查过我的文件路径,以及它们是正确的......我缺少什么?!
nothing...and I mean NOTHING is working. I've double checked my file paths, and they are correct...what am I missing?!
推荐答案
我有完全相同的问题,弹跳我的头,直到我碰到这个来一个解决方案:的http://forums.asp.net/t/1879457.aspx
I had the exact same problem, bouncing my head until I came across this for a solution : http://forums.asp.net/t/1879457.aspx
在短:
- 风格应使用@ Styles.Render呈现在页面的头
- 只有jQuery的捆绑是(使用@ Scripts.Render),至少在我的code被包含在页面头部。
- 所有其它的脚本(jQuery的一次,jQuery用户界面等),应使用页面主体呈现@ Scripts.Render 之前的结束标记 ...
- styles should be rendered using @Styles.Render in page head.
- only jquery bundle is to be included in page head (using @Scripts.Render), at least in my code.
- all other scripts (jquery again, jquery UI etc) should be rendered using @Scripts.Render in page body just before the closing body tag...
页面这样的code结尾:
The page ends with such a code :
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryui")
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/modernizr")
@RenderSection("scripts", required: false)
</body>
所以我的jQuery IU工作!
And so I got jquery IU working!
这篇关于JQuery用户界面不是MVC 4个工作Scripts.Render后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!