Setting FullCalendar Configuration Values ​​Dynamically

As part of a development project using FullCalendar, I needed to change the value of “slotMinutes” using a browser event (onClick). After some battle, I was able to find a way.

A) I have a renderCalendar () function that contains a jQuery function for building a calendar. Inside this function there is a parameter for "slotMinutes", which I point to is a variable initialized to 30.

; slotTime = 30;
...
renderCalendar () function {
. $ ('# Calendar') fullCalendar ({
firstHour: 8,
minTime: 6,
maxTime: 18,
slotMinutes: parseInt (slotTime),
defaultView: 'AgendaWeek',
...
});

B) The function of my event handler changes the value of slotTime, destroys the current calendar, and restarts the rendering function.

function changeSlotTime (slottime) {
slotTime = slottime;
$ ('# calendar') fullCalendar ('destroy') ;.
renderCalendar ();
}

C) A tough battle with this change was the understanding that the value of "slotMinutes" MUST BE INTEGRATED. Note the parseInt () function in the example in section (A).

+4
source share
2 answers

The current problem is described by the comments of the author of the FullCalendar plugin: first link , second link

+1
source

That should work.

function changeSlotTime(newTime) { $('#calendar').fullCalendar('options', 'slotTime', newTime renderCalendar(); } 
0
source

Source: https://habr.com/ru/post/1368854/


All Articles