使用 JQuery 捕获 Telerik MVC ComboBoxFor 中的更改
我使用以下代码来捕获 HTML 输入中的更改文本:
$(document).ready(function() {
$(':input', document.myForm).bind("change", function() { setConfirmUnload(true); });
});
这对于普通文本框和复选框来说效果很好。
我正在使用 Telerik 的 MVC ComboBoxFor 来呈现输入标签,但似乎没有触发上述 JQuery。
有什么想法如何捕捉这个吗?
HTML 的呈现方式如下:
<div class="t-widget t-combobox t-header" id="InterviewRequired">
<div class="t-dropdown-wrap t-state-default">
<input class="t-input" id="InterviewRequired-input" name="InterviewRequired-input" title="InterviewRequired" type="text" value="Select" />
<span class="t-select t-header">
<span class="t-icon t-arrow-down">select</span>
</span>
</div>
<input id="InterviewRequired-value" name="InterviewRequired" style="display:none" type="text" value="0" />
我还在 Telerik 论坛,以防我在这里得不到答案。
I am using the following code to capture change text in HTML inputs:
$(document).ready(function() {
$(':input', document.myForm).bind("change", function() { setConfirmUnload(true); });
});
this works fine for normal textboxes and checkboxes.
I'm using Telerik's MVC ComboBoxFor which renders input tags, but does not seem to trigger the above JQuery.
Any ideas how to capture this?
This is how the HTML renders:
<div class="t-widget t-combobox t-header" id="InterviewRequired">
<div class="t-dropdown-wrap t-state-default">
<input class="t-input" id="InterviewRequired-input" name="InterviewRequired-input" title="InterviewRequired" type="text" value="Select" />
<span class="t-select t-header">
<span class="t-icon t-arrow-down">select</span>
</span>
</div>
<input id="InterviewRequired-value" name="InterviewRequired" style="display:none" type="text" value="0" />
I've also asked this question on the Telerik forums in case I don't get an answer here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是您可以附加到的事件列表:
http://www.telerik.com/community/forums/aspnet- mvc/combobox/jquery-event-names.aspx
如果您想使用 JavaScript 以更动态的方式附加更改事件,您可以附加到“valueChange”事件而不是“change”:
Heres a list of events you can attach to:
http://www.telerik.com/community/forums/aspnet-mvc/combobox/jquery-event-names.aspx
If you want to attach the change event in a more dynamic way with javascript, you would attach to the "valueChange" event and not "change":
请在此处查看演示。 ComboBox 被渲染为
和弹出
查看客户端文档,您很可能需要注册一个客户端事件位于此处。
看起来你应该只能从这个例子中使用 jQuery 来做到这一点:
也许可以尝试:
Looking at the demo here. The ComboBox is being rendered as
<input/>
and a popup<div/>
looking at the client side docs, you most likely will need to register a Client-side event located here.
it also looks like you should be able to do it with jQuery only from this example:
Maybe try: