剑道模板复选框不会触发点击事件 [英] Kendo Template check box not firing click event
本文介绍了剑道模板复选框不会触发点击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用了剑道模板如下:
I have used Kendo Template as follows:
<script type="text/javascript" src="@Url.Content("~/Scripts/Module/Analysis/CreateMaintainAnalysis.js")"></script>
<script type="text/x-kendo-template" id="Modeltemplate">
<div class="section group fr">
<div class="col span_2_of_12">
#if(ACTIVE_MODELS_COUNT > 0){# <input class="ModelCheckBox" type="checkbox" checked/>#} else {# <input class="ModelCheckBox" type="checkbox" unchecked/> #}#
</div>
<div class="col span_4_of_12"><label>#:MODEL#</label></div>
</div>
</script>
我想在CheckBox上写点击事件点击如下:
and I want to write click event on CheckBox Click as follows:
$("#ModelListView").kendoListView({
template: kendo.template($("#Modeltemplate").html())
});
$(".ModelCheckBox").click(function () {
if (this.checked) { alert("Checked"); }
});
推荐答案
很可能,点击处理程序附加得太早,在ListView是数据绑定之前,仍然没有呈现的复选框。你有两个选择 -
Most probably, the click handler is attached too early, before the ListView is data bound, so there are still no checkboxes rendered. You have two options -
-
在
dataBound
中执行以下代码ListView的事件。
Execute the code below in the
dataBound
event of the ListView.
http://docs.telerik.com/kendo-ui/api/javascript/ui/listview#events-dataBound
$(".ModelCheckBox").click(function () {
if (this.checked) { alert("Checked"); }
});
使用附加到ListView的委托< div> ;
$("#ModelListView").on("click", ".ModelCheckBox", function () {
if (this.checked) { alert("Checked"); }
});
这篇关于剑道模板复选框不会触发点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文