在我的google MVC index.cshtml页面上,我使用ajax成功地将部分视图加载到ASP.NET地图信息窗口中,如下所示:
$.ajax({
url: '/Map/BusForm/@bus.Id',
success: function(data)
{
infoWindows["@bus.Id"].setContent(data);
}
});然后在局部视图中,我让这些表单帮助器创建下拉列表(这也是可行的,数据已正确填充,表单成功提交)。
@using (Ajax.BeginForm("BusForm", "Map", new AjaxOptions
{
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "results",
LoadingElementId = "loader"
}))
{
<h4>Line:</h4>
@*@Html.DropDownListFor(x => x.LineId, Model.GetLines(), "--Choose Train Line--")*@
@Html.DropDownListFor(x => x.LineId, Model.GetLines(), "--Choose Train Line--", new { @class = "lineDDL" })
<h4>Destination: </h4>
@Html.DropDownListFor(x => x.StationId, Model.GetStations(), "--Choose Destination--")
<div id="loader" style="display:none">Loading</div>
<div id="results"></div>
<input type="submit" value="Save" />
}
我希望使第二个下拉列表中的值与第一个下拉列表中的值相关(级联),因此我需要获取change事件。所以在Index.cshtml上,我在“脚本部分”中有这个脚本,但是它没有被调用。
$(document).ready(function() {
$("#LineId").on("change", function()
{
console.log('change was called');
});
});发布于 2015-01-13 18:39:14
哦,这太简单了。
我刚变了
$(document).ready(function() {
$("#LineId").on("change", function()
{
console.log('change was called');
});
});至
$(document).on("change", "#LineId", function()
{
console.log('change was called');
});现在它起作用了
https://stackoverflow.com/questions/27919957
复制相似问题