我使用的剑道模板如下:
<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 Click 上编写点击事件,如下所示:
$("#ModelListView").kendoListView({
template: kendo.template($("#Modeltemplate").html())
});
$(".ModelCheckBox").click(function () {
if (this.checked) { alert("Checked"); }
});
最佳答案
最有可能的是,点击处理程序附加得太早,在 ListView 数据绑定(bind)之前,所以仍然没有呈现复选框。你有两个选择-
在
dataBound
中执行下面的代码ListView 的事件。http://docs.telerik.com/kendo-ui/api/javascript/ui/listview#events-dataBound
$(".ModelCheckBox").click(function () { if (this.checked) { alert("Checked"); } });
使用附加到 ListView 的委托(delegate)
<div>
$("#ModelListView").on("click", ".ModelCheckBox", function () { if (this.checked) { alert("Checked"); } });
关于javascript - Kendo 模板复选框未触发点击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38724162/