我使用ColdFusion从http://arshaw.com/fullcalendar/实现了FullCalendar。我将事件从外部丢弃到日历。这很好用,但我不能用
更新事件$('#calendar').fullCalendar('updateEvent', responseText.NewID);
我需要这样做,我可以将来自dem数据库的新ID放在事件上,用于其他操作,例如Resize,Drop to other Day或Delete it。
我可以从整个网站进行重新加载,但它不是真正的用户友好,因为月份实际上是月份,而不是我之前选择的月份。
我的代码如下:
drop: function(date, allDay) { // this function is called when something is dropped
// retrieve the dropped element's stored Event Object
var originalEventObject = $(this).data('eventObject');
// we need to copy it, so that multiple events don't have a reference to the same object
var copiedEventObject = $.extend({}, originalEventObject);
// assign it the date that was reported
copiedEventObject.start = date;
copiedEventObject.allDay = allDay;
// render the event on the calendar
// the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)
$('#calendar').fullCalendar('renderEvent', copiedEventObject, true);
var formdata = "startdatum="+copiedEventObject.start;
$.ajax({
url: '<cfoutput>#application.TartalomURL#</cfoutput>mod_Kalender/act_event_ins.cfm',
data: formdata,
type: "POST",
dataType: "json",
cache: false,
success: function(responseText){
$('#calendar').fullCalendar('updateEvent', responseText.NewID);
}
});
},
有人知道我编程错了吗?
答案 0 :(得分:3)
请参阅fullcalendar文档: arshaw fullcalendar updateEvent
您需要使用updateEvent方法的事件,例如:
$.ajax({
url: '<cfoutput>#application.TartalomURL#</cfoutput>mod_Kalender/act_event_ins.cfm',
data: formdata,
type: "POST",
dataType: "json",
cache: false,
success: function(responseText){
originalEvent.id = responseText.newid; //use the originating event object and update it
$('#calendar').fullCalendar('updateEvent', originalEvent);
}
});
答案 1 :(得分:2)
由于JavaScript区分大小写,因此该行:
$('#calendar').fullCalendar('updateEvent', responseText.NewID)
是
$('#calendar').fullCalendar('updateEvent', responseText.newid)