我使用的 Kendo 模板如下:
<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 进行数据绑定之前,单击处理程序附加得太早,因此仍然没有呈现复选框。你有两个选择——
-
在下面的代码中执行dataBound
ListView 的事件。
http://docs.telerik.com/kendo-ui/api/javascript/ui/listview#events-dataBound 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"); }
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)