[英].Net MVC 3 Telerik DropDownList not firing event OnChange
I have a DropDownList
which has a bind to a ViewData
which populates the list perfectly. 我有一个
DropDownList
,它绑定到ViewData
,后者完美地填充了列表。
I would like to commit the user selection when "OnChange" event fires. 我想在触发“ OnChange”事件时提交用户选择。 But I am struggling to make it work, in fact nothing happen.
但是我努力使它起作用,实际上什么也没发生。
<fieldset style="width: 300px;">
<legend>Change Vehicle</legend>
@{Html.Telerik().DropDownList()
.Name("UpdateVehicleTypeNumbers")
.BindTo((IEnumerable<DropDownItem>)ViewData["PlantItemsDropDown"])
.Enable(true)
.ClientEvents(events => events.OnChange("submitVehicle"))
.HtmlAttributes(
new { @id = "vehicle"})
.Render();
}
</fieldset>
I think the error might be in theJavaScript code. 我认为错误可能出在JavaScript代码中。
function submitVehicle(){
window.location = '../Operator/GPS?jobId=' + @the_job_id + '&vehicleId=' + $("#vehicle").val();
}
I found the solution: apparently Telerik elements can be accessed with the name convention: tElementName
in my case the following code worked: 我找到了解决办法:显然Telerik的元素可以与命名规范进行访问:
tElementName
在我的情况下,下面的代码工作:
function submitVehicle(){
var veh = $("#UpdateVehicleTypeNumbers").data("tDropDownList").value();
//etc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.