In fullCalendar change slotDuration without page reloading

一曲冷凌霜 提交于 2020-01-12 09:36:25

问题


Using fullcalendar I need without page reloading to change slotDuration parameter depending on other conditions:

I do in one case

$('#calendar').fullCalendar('option', 'slotDuration', '00:15:00');

and in other case

$('#calendar').fullCalendar('option', 'slotDuration', '00:30:00');

But looks like it does not work, as I always see fullcalendar with slotDuration=30 (2 slots) minutes, as it was called when initialized.

If there is a way for this?


回答1:


Now, you can set dynamically without destorying the calendar.

$('#cc-calendar')
  .fullCalendar('option','slotDuration','00:10:00');

Here, we work with the Dynamically get/set Options feature of fullcalendar.

For more info, check out : https://fullcalendar.io/docs/utilities/dynamic_options/

Good Luck.




回答2:


As you can see here, fullCalendar only allow change some properties after initialization. You don't need to reload the page, but destroy and init is required.

So:

var calendarOptions = {
    defaultView: 'month', 
    editable: true,
    slotDuration: '00:45:00', 
    (...)
}
$('#calendar').fullCalendar(calendarOptions); //Init

//And when you need to update any property

calendarOptions.slotDuration = '00:15:00';
$('#calendar').fullCalendar('destroy');
$('#calendar').fullCalendar(calendarOptions);


来源:https://stackoverflow.com/questions/26882176/in-fullcalendar-change-slotduration-without-page-reloading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!