在fullcalendar中,添加事件时,如果用户在不刷新的情况下调整该事件的大小,则修改不会在数据库中更新。插入和修改操作非常完美。
这是我的插入代码
$.ajax({
url: 'events.add.php',
data: 'start='+ copiedEventObject.start
+'&end='+ copiedEventObject.end
+'&color='+ copiedEventObject.backgroundColor
+'&title='+ copiedEventObject.title
+'&cure_type='+ copiedEventObject.cure_type,
type: "POST",
success: function(json) {
location.reload();
// I wish not to use this refresh method because then I loose the location of the calendar. The calendar comes back to today's date.
}
});
if ($('#drop-remove').is(':checked')) {
// if so, remove the element from the "Draggable Events" list
$(this).remove();
}
这是我的更新代码
// load events from MySQL
events:'events.json.php',
// if event is moved around in the calendar
eventDrop: function(event, delta) {
start = $.fullCalendar.formatDate(event.start, "yyyy-MM-dd HH:mm:ss");
end = $.fullCalendar.formatDate(event.end, "yyyy-MM-dd HH:mm:ss");
startTime = $.fullCalendar.formatDate(event.start, "Hmm");
$.ajax({
url: 'events.update.php',
data: 'start='+ start +'&end='+ end +'&id='+ event.id,
type: "POST",
success: function(json) {
//alert("Updated Successfully");
}
});
},
// if event is rezided in the calendar
eventResize: function(event) {
start = $.fullCalendar.formatDate(event.start, "yyyy-MM-dd HH:mm:ss");
end = $.fullCalendar.formatDate(event.end, "yyyy-MM-dd HH:mm:ss");
$.ajax({
url: 'events.update.php',
data: 'start='+ start +'&end='+ end +'&id='+ event.id,
type: "POST",
success: function(json) {
//alert("Updated Successfully");
}
});
}
我尝试过使用它,但它不起作用。
type: "POST",
success: function(json) {
//location.reload();
$('#calendar').fullCalendar('refetchEvents');
}
它确实刷新了页面,但它复制了我的事件。。。那么如果我刷新页面,它就会工作。