gpt4 book ai didi

javascript - 删除外部事件时在 FullCalendar 上获取资源 ID

转载 作者:行者123 更新时间:2023-12-05 06:47:15 24 4
gpt4 key购买 nike

我使用的是 FullCalendar jQuery plugin 的版本支持资源。

我正在根据 this example 拖入外部事件.

一切都很好,但我找不到一种方法来获取与已放置外部事件的单元格(天)相关联的资源 ID

我正在使用下面的 drop 函数。

drop: function(date, allDay) { 
// this function is called when something is dropped
// retrieve the dropped element's stored Event Object
var originalEventObject = $(this).data('eventObject');

// we need to copy it, so that multiple events
// don't have a reference to the same object
var copiedEventObject = $.extend({}, originalEventObject);

// assign it the date that was reported
copiedEventObject.start = date;
copiedEventObject.allDay = allDay;

// render the event on the calendar
// the last `true` argument determines if the event "sticks"
// (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)
$('#calendar').fullCalendar('renderEvent', copiedEventObject, true);

// is the "remove after drop" checkbox checked?
if ($('#drop-remove').is(':checked')) {
// if so, remove the element from the "Draggable Events" list
$(this).remove();
}
}

如果您对此有任何帮助,我将不胜感激。

最佳答案

我也使用 FullCalendar 的这个分支,当你删除一个事件时可以获取资源 ID,如下所示:

drop: function(date, allDay, test3, test4, resource) {          
var originalEventObject = $(this).data('eventObject');
var copiedEventObject = $.extend({}, originalEventObject);
copiedEventObject.start = date;
copiedEventObject.allDay = allDay;
copiedEventObject.resource = resource.id;

$('#calendar').fullCalendar('renderEvent', copiedEventObject, true);

if ($('#drop-remove').is(':checked')) {
$(this).remove();
}
}

因此,您应该将参数resource传递给drop函数,您可以通过调用resource.id获取资源ID。

关于javascript - 删除外部事件时在 FullCalendar 上获取资源 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11968266/

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