全日历。从外部列表中删除拖动的事件

Fullcalendar. Delete dragged events from external list

我正在使用 Fullcalendar 4 并且在刷新事件时遇到问题。我正在使用下拉菜单更改事件源,但我只能重新获取存储在 json 中的事件,而不是动态拖动的事件。我正在使用以下代码。

calendar.destroy();
var eventSources = calendar.getEventSources();
var len = eventSources.length;
for (var i = 0; i < len; i++) { 
eventSources[i].remove(); 
}
var url = './demo2/contents/calendar/get.php?source='+source;
calendar.addEventSource(url);
calendar.refetchEvents();
calendar.render();

如何使用 eventReceive 将所有拖动的事件添加到新源?

eventReceive: function(info) {
calendar.addEvent(event,  [, source ]);    
},

外部列表是用下面的代码生成的,我试图指定源位置,但是当我从外部列表中拖放时似乎不起作用:

var initDrag = function(el,value) {

 var eventObject = {

 id: el.attr("data-id"),
 startEditable: true,
 allDay: false,
 durationEditable: true,
 title: $.trim(el.text()), // use the element's text as the event title
 stick: true, // maintain when user navigates (see docs on the renderEvent method)
 classNames: [el.attr("data-color"),],
 description: 'Lorem ipsum dolor eius mod tempor labore',
 source: 'planificacion'
 };

 // store the Event Object in the DOM element so we can get to it later
 el.data('event', eventObject);

 };

感谢 ADyson,你解决了我的问题。这个解决方案有效。

eventReceive: function(info) { // called when a proper external event is dropped

 var evt = info.event;
 evt.remove();
 var newEvent = {};
 //clone the object - doesn't work if we just pass evt straight to the addEvent method
 for (prop in evt) {
 newEvent[prop] = evt[prop];
 }

 calendar.addEvent(newEvent,'planificacion');

}