Googleのバンドルなどを使用しない答えが見つかりません。詳細が不足している場合は追加してください。私は( '...')。それぞれがasp.netの有効な関数ではありません。jveryバンドルを持つcore mvc
@Scripts.Render("~/bundles/jquery")
... VSは私_layoutの上部に参照して全体jqueryのバンドルが含まれていここ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"));
}
だ...しかし、それはまだこのケースでは私に言っていますその.each
は機能ではありません。レイアウトやBundleConfigを参照する必要がありますか? .each
は、Visual Studio 2017に付属するjqueryバンドルの一部である関数ではないのはなぜですか?
@Html.ListBox("Groups", null, new { size = 10, style = "width : 350px; max-width : 500px;", id = "grouplist" })
私の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),
});
});
:あなたはjQueryのセレクタが欠落しているよう
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)
変更**( '#grouplist')** to ** $( '#grouplist')** – gaetanoM
私はそれを試みましたが、その時点でループ全体をスキップしました。 –