我有两个下拉列表。区域和子区域。当我选择一个区域时,我想填充子区域下拉列表。我有它所有的工作没有击倒,但我不知道如何使用击倒数据绑定,而不是js做处理变化事件。
脚本:? ?
html:<div class="col-md-10">
@Html.LabelFor(model => model.AreaID, new { @class = "control-label col-md-2" })
@Html.DropDownList("AreaID", AreaList, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.AreaID)
</div>
<div class="col-md-10">
@Html.LabelFor(model => model.AreaNodeID, new { @class = "control-label col-md-2" })
@Html.DropDownList("AreaNodeID", new List<SelectListItem>(), new { @class = "form-control" } )
@Html.ValidationMessageFor(model => model.AreaNodeID)
</div>
@Html.DropDownList("AreaID", AreaList, new { @class = "form-control" },
new { onchange = "FetchStates();" })
function FetchStates() {
var countryCode = $("#AreaID").val();
$.getJSON("/Home/GetStates/" + countryCode, null, function (data) {
objVM.states(data);
});