Pie*_*NAY 5 javascript jquery fullcalendar
我希望能够更改任何新创建的事件的默认持续时间。
我在 dayView 中,如果我只需单击(而不是拖放)日历,我就会获得半小时的会话。
我想默认将其设置为一小时。
也许用这样的代码:
, select: function (startDate, endDate, allDay, jsEvent, view) {
endDate = new Date(startDate);
endDate.setHours(endDate.getHours() + 1);
}
Run Code Online (Sandbox Code Playgroud)
这有效地设置了良好的结束日期,但没有视觉更新

编辑
我试图使行为类似于 Google 日历:如果用户单击它将选择 1 小时事件,但用户仍然可以选择半小时。
基于示例之一:
select: function(start, end, allDay) {
var title = prompt('Event Title:');
if (title) {
end = new Date(start);
end.setHours(end.getHours() + 1);
calendar.fullCalendar('renderEvent',
{
title: title,
start: start,
end: end,
allDay: allDay
},
true // make the event "stick"
);
}
calendar.fullCalendar('unselect');
},
Run Code Online (Sandbox Code Playgroud)
在问题更新之前:
像这样的东西应该有效:
eventClick: function (calEvent, jsEvent, view) {
calEvent.end = new Date(calEvent.start);
calEvent.end.setHours(calEvent.start.getHours() + 1);
$('#calendar').fullCalendar('updateEvent', calEvent);
},
Run Code Online (Sandbox Code Playgroud)