ASP.NET AJAX CascadingDropDown 的 jQuery 更改值
我可以使用 jQuery 更改 CascadingDropDown 的值,但是触发导致目标控件的子下拉列表填充数据的事件永远不会发生:
$("#<%= ddlFromCompetition.ClientID %>").change(function() {
var fromValue = $("#<%= ddlFromCompetition.ClientID %>").val();
$("#<%= ddlToCompetition.ClientID %>").val(fromValue); // causes value to change, but child doesn't update
});
需要明确的是,ddlFromCompetition
和 ddlToCompetition
code> 不是父/子。它是 ddlToCompetition
的子项,不会使用上述代码进行更新。使用鼠标选择 ddlToCompetition 时,其子下拉列表会按预期更新。
我尝试调用 $("#<%= ddlToCompetition.ClientID %>").change()
来尝试强制触发事件,但它不起作用。
I can use jQuery to change the value of a CascadingDropDown, but the event that fires which causes the target control's child dropdown to populate with data never happens:
$("#<%= ddlFromCompetition.ClientID %>").change(function() {
var fromValue = $("#<%= ddlFromCompetition.ClientID %>").val();
$("#<%= ddlToCompetition.ClientID %>").val(fromValue); // causes value to change, but child doesn't update
});
To be clear, ddlFromCompetition
and ddlToCompetition
are not parent/child. It's the child of ddlToCompetition
that does not update using the above code. When selecting ddlToCompetition
using the mouse, its child dropdown updates as expected.
I've tried calling $("#<%= ddlToCompetition.ClientID %>").change()
to try to force the event to fire, but it doesn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要trigger()事件
JQuery文档:http://api.jquery.com/trigger/
此外,由于 ddlFromCompetition 的第一个更改事件处理程序在 ddlFromCompetition 的上下文中触发,因此您应该能够将...更改
为...
You need the trigger() event
JQuery docs: http://api.jquery.com/trigger/
Also, because the first change event handler for ddlFromCompetition fires in the context of ddlFromCompetition, you should be able to change...
to...