使用Fullcalendar管理日程事件(增删改查拖放) 附代码
时间: 2023-04-06 15:01:28 浏览: 247
用fullcalendar做的日程管理
4星 · 用户满意度95%
非常感谢您的问题。以下是使用Fullcalendar管理日程事件的代码示例:
HTML代码:
```
<div id="calendar"></div>
```
JavaScript代码:
```
$(document).ready(function() {
var calendar = $('#calendar').fullCalendar({
editable: true,
events: [
{
title: 'Event 1',
start: '2021-06-01'
},
{
title: 'Event 2',
start: '2021-06-05',
end: '2021-06-07'
},
{
title: 'Event 3',
start: '2021-06-09T12:30:00',
allDay: false
}
],
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
selectable: true,
selectHelper: true,
select: function(start, end) {
var title = prompt('Event Title:');
var eventData;
if (title) {
eventData = {
title: title,
start: start,
end: end
};
calendar.fullCalendar('renderEvent', eventData, true);
}
calendar.fullCalendar('unselect');
},
editable: true,
eventDrop: function(event, delta, revertFunc) {
alert(event.title + " was dropped on " + event.start.format());
if (!confirm("Are you sure about this change?")) {
revertFunc();
}
},
eventResize: function(event, delta, revertFunc) {
alert(event.title + " end is now " + event.end.format());
if (!confirm("is this okay?")) {
revertFunc();
}
}
});
});
```
希望这个代码示例能够帮助您管理日程事件。如果您有任何其他问题,请随时问我。
阅读全文