在kendo ui widget代码被触发后,我没有看到添加回调的文档。我有以下kendo ui小部件声明。
$("#scheduler").kendoScheduler({
date: new Date("2013/6/13"), // Change this to current date with twig
startTime: new Date("2013/6/13 07:00 AM"), // Change this to 12:00 AM of current date
allDaySlot: false,
width:600,
height:500,
resize: function(e) {
if (careGiverIsOccupied(e.start, e.end, e.event, e.resources)) {
this.wrapper.find(".k-marquee-color").addClass("invalid-slot");
e.preventDefault();
}
},
resizeEnd: function(e) {
if (!checkAvailability(e.start, e.end, e.events)) {
e.preventDefault();
}
},
move: function(e) {
if (careGiverIsOccupied(e.start, e.end, e.event, e.resources)) {
this.wrapper.find(".k-event-drag-hint").addClass("invalid-slot");
}
},
moveEnd: function(e) {
if (!checkAvailability(e.start, e.end, e.event, e.resources)) {
e.preventDefault();
}
},
add: function(e) {
if (!checkAvailability(e.event.start, e.event.end, e.event)) {
e.preventDefault();
}
changeColors();
},
save: function(e) {
if (!checkAvailability(e.event.start, e.event.end, e.event)) {
e.preventDefault();
}
changeColors();
},
views: [
"week",
"month"
],
dataSource: {
data: [
{
eventID: 2,
title: "Hey man",
start: new Date("2013/6/13 12:00"),
end: new Date("2013/6/13 13:30"),
pending: true,
permissionToDelete: false,
careGiverId: 1
},
{
eventID: 1,
title: "Call Charlie about the project",
start: new Date("2013/6/13 10:30"),
end: new Date("2013/6/13 11:30"),
pending: false,
permissionToDelete: false,
careGiverId: 1
}
],
schema: {
model: {
id: "eventID",
fields: {
eventID: { type: "number" },
title: { defaultValue: "No title", validation: { required: true } },
start: { type: "date" },
end: { type: "date" },
careGiverId: { nullable: true },
pending: { type: "boolean", defaultValue:true },
permissionToDelete: { type: "boolean", defaultValue:true },
isAllDay: { type: "boolean" }
}
}
}
},
group: {
resources: [ "care" ]
},
resources: [
{
field: "careGiverId",
name: "care",
dataSource: [
{
// Change the text with care giver name, change value with care giver id
text: "Jeffery Dohmer (Care Giver 1)", value: 1, color: "#00FF00"
}
],
title: "Care"
}
]
});
问题是在调用resizeEnd,move,moveEnd,add和save之类的事件处理程序之后,我的文档的dom结构被修改了。我想做的是在kendoScheduler添加或节省时间之后更改特定元素的颜色。无论如何在完成后添加回调?
答案 0 :(得分:0)
查看此post中的完整事件示例:
read: {
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
url: _op.serviceBaseUrl + "ReadX",
complete: function () {
console.log('Tweak your UI here');
}
}
显然,只有在使用remote data.时才能使用“完整”事件。
除此之外,请查看此requestEnd
event:
requestEnd: function(e) {
var response = e.response;
var type = e.type;
console.log(type); // displays "read"
console.log(response.length); // displays "77"
}
使用e.type
上的开关来区分不同的操作(请求的类型。设置为“创建”,“读取”,“更新”或“销毁”。)
答案 1 :(得分:0)
我找到了这个问题的优雅答案。显然有一个名为dataBound的事件:允许一个事件完成后触发回调。
在我的情况下,我想使用:
dataBound: function(e){
// Code after widget is finished processing everything
}