我有一个kendo网格,只要我转到下一页或使用我的过滤器,它就不再为我的instructionsButton
或tipsButton
点击我的点击事件。 click事件正常工作,直到我与网格交互。
$(document).ready(function () {
$("#clientsDb").kendoGrid({
dataSource: {
pageSize: 15
},
sortable: true,
pageable: true,
filterable: true,
groupable: true,
scrollable: false,
resizable: true
}).data("kendoGrid");
$("#FieldFilter").keyup(function () {
var value = $("#FieldFilter").val();
var grid = $("#clientsDb").data("kendoGrid");
if (value) {
grid.dataSource.filter({
logic: "or",
filters: [
{ field: "TaskName", operator: "contains", value: value }
]
});
} else {
grid.dataSource.filter({});
}
});
kendo.ui.editor.ColorTool.prototype.options.palette = "basic";
$('.instructionsButton').one("click", function () {
var target = $(this).attr('data-target');
$(target + " " + ".editor").kendoEditor({
resizable: {
content: true,
toolbar: true
},
tools: [
"formatting",
"bold",
"italic",
"underline",
"justifyLeft",
"justifyCenter",
"justifyRight",
"justifyFull",
"insertUnorderedList",
"insertOrderedList",
"indent",
"outdent",
"createLink",
"unlink",
"foreColor",
"backColor"
],
paste: function (ev) {
ev.html = $(ev.html).text();
}
});
});
$('.tipsButton').one("click", function () {
var target = $(this).attr('data-target');
$(target + " " + ".editor").kendoEditor({
resizable: {
content: true,
toolbar: true
},
tools: [
"formatting",
"bold",
"italic",
"underline",
"justifyLeft",
"justifyCenter",
"justifyRight",
"justifyFull",
"insertUnorderedList",
"insertOrderedList",
"indent",
"outdent",
"createLink",
"unlink",
"foreColor",
"backColor"
],
paste: function (ev) {
ev.html = $(ev.html).text();
}
});
});
});
我有什么
$(document).delegate('.tipsButton', "click", function () {
var target = $(this).attr('data-target');
$(target + " " + ".editor").kendoEditor({
resizable: {
content: true,
toolbar: true
},
tools: [
"formatting",
"bold",
"italic",
"underline",
"justifyLeft",
"justifyCenter",
"justifyRight",
"justifyFull",
"insertUnorderedList",
"insertOrderedList",
"indent",
"outdent",
"createLink",
"unlink",
"foreColor",
"backColor"
],
paste: function (ev) {
ev.html = $(ev.html).text();
}
});
});
答案 0 :(得分:1)
您需要使用委托,因为页面上没有的元素不会绑定到事件。如果你做类似的事情:
$(document).delegate("classOrId", "eventType", function () {
// Do function stuff here
});
然后eventType
会触发您放入classOrId
的所有网页上的元素。