Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In fullCalendar change slotDuration without page reloading

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?

like image 343
user2339232 Avatar asked Dec 19 '22 09:12

user2339232


2 Answers

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.

like image 54
Aakash Avatar answered Mar 07 '23 11:03

Aakash


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);
like image 22
Mario Levrero Avatar answered Mar 07 '23 10:03

Mario Levrero