我正在使用 Fullcalendar,我必须在开始日期和结束日期之间的同一时间创建一个事件。这里我的开始日期和结束日期不同,但我必须在开始日期和结束日期之间的每一天/日期同时创建事件。
我无法将上述场景转化为代码。 以下是我用于创建事件的数组中的数据:
createEvent=[{标题:'QuoteIT',resourceId:'423759xxxx00517869',开始:'2023-09-08T15:00:00+05:30',结束:'2023-09-08T18:00:00+05: 30', woid: '423759xxxxxx0068101, …}, {title: '内部公司', resourceId: '42375900xxxx517869', start: '2023-09-15T14:00:00+05:30', end: '2023-09-16T16:00:00+05:30', woid: '423759xxxxxxx01220009', …}]
这里我使用下面的 jquery 代码创建事件:
事件:创建事件
// Your data array
var createEvent = [
{
title: 'QuoteIT',
resourceId: '423759xxxx00517869',
start: '2023-09-08T15:00:00+05:30',
end: '2023-09-08T18:00:00+05:30',
woid: '423759xxxxxx0068101'
},
{
title: 'Internal Company',
resourceId: '42375900xxxx517869',
start: '2023-09-15T14:00:00+05:30',
end: '2023-09-16T16:00:00+05:30',
woid: '423759xxxxxxx01220009'
}
];
// Initialize FullCalendar
var calendar = $('#calendar').fullCalendar({
// Your FullCalendar options here
// ...
// Define an event source
events: function (start, end, timezone, callback) {
var events = [];
// Loop through each event in your data array
$.each(createEvent, function (index, eventData) {
var startDate = moment(eventData.start);
var endDate = moment(eventData.end);
// Generate events for each day between start and end dates
while (startDate.isSameOrBefore(endDate, 'day')) {
events.push({
title: eventData.title,
resourceId: eventData.resourceId,
start: startDate.format(),
end: endDate.format(),
woid: eventData.woid
});
// Move to the next day
startDate.add(1, 'day');
endDate.add(1, 'day');
}
});
// Call the callback function with the generated events
callback(events);
}
});