FullCalendar: Drop an event but can't update this event
I implemented the FullCalendar from http://arshaw.com/fullcalendar/ with ColdFusion. I drop the events from outside to the calendar. This is working well, but i can't update the Event with
$('#calendar').fullCalendar('updateEvent', responseText.NewID);
I need to do this, that I can put the new ID from dem Database o开发者_JAVA技巧n the Event, for other actions like Resize, Drop to other Day or to Delete it.
I could do a Reload from the whole site, but it's not really userfriendly, because the month would be the actually month and not the month I selected before.
My Code looks like this:
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);
}
});
},
Does anyone has an idea what I'm programming wrong?
Please refer to the fullcalendar documentation: arshaw fullcalendar updateEvent
You need the event for using the updateEvent method i.e.:
$.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);
}
});
As JavaScript is case-sensitive, should this line:
$('#calendar').fullCalendar('updateEvent', responseText.NewID)
be
$('#calendar').fullCalendar('updateEvent', responseText.newid)
精彩评论