现在,当我在周视图中点击日历时,它默认为30分钟的插槽。我可以扩展它,但它总是以30分钟开始。
09:30-10:00
12:00-12:30
17:30-18:00
我想改变它,所以默认为一小时。理想情况下,当我点击日历时,它将以60分钟的块开始。
09:30-10:30
12:00-13:00
17:30-18:30
答案 0 :(得分:4)
There is this option called defaultTimedEventDuration but I never succeeded to use it...
However you can modify the event after clicking on the calendar: after the select
method, you simply calculate the event's end date and you render
the event:
select: function(start, end) {
end = $.fullCalendar.moment(start);
end.add(1, 'hours');
$('#calendar').fullCalendar('renderEvent',
{
start: start,
end: end,
allDay: false
},
true // stick the event
);
$('#calendar').fullCalendar('unselect');
}
Here is a working jsFiddle.
Edit: to calculate the end date, I use Moment.js which comes with FullCalendar v2. But a Javascript Date() would work too.
答案 1 :(得分:3)
在文件fullcalendar.min.js中 在最后一行找到
slotDuration:"00:30:00"
更改为
slotDuration:"01:00:00"
答案 2 :(得分:1)
snapDuration: "01:00:00"
答案 3 :(得分:0)
如果将forceEventDuration设置为true,则可以为defaultTimedEventDuration设置时间。添加以下代码,它将设置1小时作为事件的默认值。
$('#calendar').fullCalendar({
forceEventDuration : true,
defaultTimedEventDuration : "01:00:00"
});
答案 4 :(得分:0)
您也可以像下面一样在select方法中修改持续时间
select: function(arg) {
calendar.addEvent({
title: title,
start: arg.start,
end: arg.end.getMinutes() +50,
allDay: arg.allDay
});
calendar.unselect()
}