我有一个包含一些下拉菜单这样的MVC观点:加载页面上的运行代码?
<%: Html.DropDownListFor(model => model.CS.C1, Model.CS.Category1List, "-- Välj kategori --")%>
<%: Html.DropDownListFor(model => model.CS.C2, Model.CS.Category2List, "-- Välj kategori --")%>
<%: Html.DropDownListFor(model => model.CS.C3, Model.CS.Category3List, "-- Välj kategori --")%>
<%: Html.DropDownListFor(model => model.CS.C4, Model.CS.Category4List, "-- Välj kategori --")%>
<%: Html.DropDownListFor(model => model.CS.C5, Model.CS.Category5List, "-- Välj kategori --")%>
<%: Html.DropDownListFor(model => model.CS.C6, Model.CS.Category6List, "-- Välj kategori --")%>
要使用AJAX恭维这个电话(创建CascadingDropDown)我有以下的javascript:
$(document).ready(function() {
$("#CS_C1").change(function() { lastCategoryId = $("#CS_C1").val() });
$("#CS_C2").change(function() { lastCategoryId = $("#CS_C2").val() });
$("#CS_C3").change(function() { lastCategoryId = $("#CS_C3").val() });
$("#CS_C4").change(function() { lastCategoryId = $("#CS_C4").val() });
$("#CS_C5").change(function() { lastCategoryId = $("#CS_C5").val() });
$("#CS_C6").change(function() { lastCategoryId = $("#CS_C6").val() });
$("#CS_C2").CascadingDropDownCategory("#CS_C1", '/AdCategory/GetCategoriesByParent', '', true, SetFilter);
$("#CS_C3").CascadingDropDownCategory("#CS_C2", '/AdCategory/GetCategoriesByParent', '', true, SetFilter);
$("#CS_C4").CascadingDropDownCategory("#CS_C3", '/AdCategory/GetCategoriesByParent', '', true, SetFilter);
$("#CS_C5").CascadingDropDownCategory("#CS_C4", '/AdCategory/GetCategoriesByParent', '', true, SetFilter);
$("#CS_C6").CascadingDropDownCategory("#CS_C5", '/AdCategory/GetCategoriesByParent', '', true, SetFilter);
$("#LS_L2").CascadingDropDown("#LS_L1", '/Location/GetLocationsByParent', '', true);
alert(lastCategoryId);
SetFilter(lastCategoryId);
});
的CascadingDropDownCategory功能是从this site。
当执行后的下拉菜单设置properply但在运行时
SetFilter(lastCategoryId);
的lastCategoryId是梁-1?我可以看到,下拉菜单有价值,也应该引发变化事件?为什么我得到-1?我怎么解决它?
BestRegards
有这个东西叫做循环... – Skilldrick 2010-10-03 11:33:19