gpt4 book ai didi

javascript - 事件删除后全日历不刷新

转载 作者:行者123 更新时间:2023-12-01 05:46:17 25 4
gpt4 key购买 nike

在 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');
}

它确实刷新了页面,但它重复了我的事件...然后如果我刷新页面,它就会起作用。

关于javascript - 事件删除后全日历不刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26523082/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com