我对全日历 v4 有问题。我尝试了几天来获取在外部列表中声明的对象的 id,如下所示,但没有运气。
$(this).data('event', {
id: 2,
title: $.trim($(this).text()), // use the element's text as the event title
stick: true, // maintain when user navigates (see docs on the renderEvent method)
classNames: [$(this).data('color')],
description: 'Lorem ipsum dolor eius mod tempor labore'
});
在日历中:
var Draggable = FullCalendarInteraction.Draggable;
new Draggable(containerEl, {
itemSelector: '.fc-draggable-handle',
eventData: function(eventEl) {
return $(eventEl).data('event');
}
});
然后尝试在丢弃或事件接收时检索数据:
eventReceive: function(event, view) {
alert("Dropped event: " + event); // any data linked to the dropped event
var datax = $(this).data('event');
console.log(datax);
},
drop: function(arg) {
console.log(arg.draggedEl);
// is the "remove after drop" checkbox checked?
if ($('#kt_calendar_external_events_remove').is(':checked')) {
// if so, remove the element from the "Draggable Events" list
$(arg.draggedEl).remove();
}
},
这是我使用 eventReceive 找到的解决方案:
eventReceive: function(event) {
// called when a proper external event is dropped
console.log('eventReceive', event);
},