Javascript Fullcalendar:删除时重复条目(外部)
我使用修改删除的元素(title、id和date),并在fullcalendar的drop函数中获取回调Javascript Fullcalendar:删除时重复条目(外部),javascript,jquery,drag-and-drop,fullcalendar,Javascript,Jquery,Drag And Drop,Fullcalendar,我使用修改删除的元素(title、id和date),并在fullcalendar的drop函数中获取回调 var url = "json-save-urlaub.php?event="+date.format()+"&allDay="+date.hasTime(); $.post( url, function(data){ //callback fun
var url = "json-save-urlaub.php?event="+date.format()+"&allDay="+date.hasTime();
$.post(
url,
function(data){ //callback function retrieving the response sent by the controller/action
//event is the object that will actually be rendered to the calendar
var event = jQuery.parseJSON(data);
//actually rendering the new event to the calendar
$('#calendar').fullCalendar('renderEvent', event, true);
//$('#calendar').fullCalendar('refetchEvents');
$('#calendar').fullCalendar('unselect');
}
);
但是现在,当我在fullcalendar上删除元素时,我有两个条目,因为回调给了我一个新的事件对象,而删除的那个条目我不能删除,因为它没有id,我不能手动删除它,我也不能将它用于URL调用
行
$(this.remove()代码>无效。两者都没有$(“#日历”).fullCalendar('removeEvents',CopiedEventToObject.\u id)代码>首先复制删除的元素时。如何在删除元素时只保留一个元素?根据
通常,一旦日历重新提取事件源(例如:单击“上一步/下一步”),事件将消失。但是,将“保持”指定为“真”将导致事件永久固定到日历上
创建对象时,需要将对象内的数据设置为“不粘滞”。例如,stick:false
,或者只需删除您的stick:true
$('#external-events .fc-event').each(function() {
// store data so the calendar knows to render an event upon drop
$(this).data('event', {
title: $.trim($(this).text()), // use the element's text as the event title
stick: false // (see docs on the renderEvent method)
});
// make the event draggable using jQuery UI
$(this).draggable({
zIndex: 999,
revert: true, // will cause the event to go back to its
revertDuration: 0 // original position after the drag
});
});
更新:这个例子展示了外部事件是如何持续的,或者在我的例子中它是如何不应该持续的。已解决重复条目问题您如何解决此问题?