[英]('…').each not a valid function for asp.net core mvc with jquery bundle
Reposting this because I cannot find any answer that doesn't involve using Google's bundle or something else. 重新发布此内容是因为我找不到任何不涉及使用Google捆绑软件或其他工具的答案。 Please tell me if I'm missing any detail so I'll add it.
请告诉我是否缺少任何细节,所以我将其添加。 I have the whole jquery bundle included with VS referenced at the top of my _Layout...
我在_Layout的顶部引用了VS随附的整个jquery包...
@Scripts.Render("~/bundles/jquery")
Here's the BundleConfig.cs 这是BundleConfig.cs
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/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 ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/respond.js"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/site.css"));
}
...but it is still telling me in this case that .each
is not a function. ...但是在这种情况下,它仍然告诉我
.each
不是函数。 What I'm missing or need to refer to the layout or BundleConfig? 我所缺少的或需要引用的布局或BundleConfig? Why isn't
.each
a function that is a part of the jquery bundle that comes with Visual Studio 2017? 为什么
.each
不是Visual Studio 2017随附的jquery捆绑包中的一部分的函数?
@Html.ListBox("Groups", null, new { size = 10, style = "width : 350px; max-width : 500px;", id = "grouplist" })
The whole context of my jquery: 我的jQuery的整个上下文:
$('#savegroups').click(function () {
var groupId = $('#groupId').val();
var list = [];
('#grouplist').each(function (item) {
list.append('{"groupId":"' + groupId + '","groupName":"' + item.value +'"}');
});
$.ajax({
type: "POST",
url: "/GroupCategories/EditGroups",
data: JSON.stringify(list),
});
});
Error: 错误:
1:230 Uncaught TypeError: "#grouplist".each is not a function
at HTMLInputElement.<anonymous> (1:230)
at HTMLInputElement.dispatch (jquery:1)
at HTMLInputElement.y.handle (jquery:1)
Looks like you are missing the jquery selector.. 看起来您缺少jquery选择器。
('#grouplist')
should be 应该
$('#grouplist option')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.