On my website, I put the buttons “Hide free time” and “Show free time”.
When a user click “Hide”, the following code will run to fetch the “freeTime” array with all the Event objects with id ‘regular’ and ‘relief’:
function hideFreeTime() {
freeTime.length = 0;
freeTime = $('#calendar').fullCalendar('clientEvents', 'free');
$('#calendar').fullCalendar('removeEvents', 'free');
}
When a user click “Show”, the following code will run to render the Event objects in the “freeTime” array:
function showFreeTime() {
for(var i = 0; i < freeTime.length; i++) {
$('#calendar').fullCalendar('renderEvent', freeTime[i]);
}
}
The above codes can hide the events but I have no idea why it cannot re-render the hidden events.
However, it would work if I change the “showFreeTime()” function as following:
function showFreeTime() {
for(var i = 0; i < freeTime.length; i++) {
if (freeTime[i].id == 'regular') $('#calendar').fullCalendar('renderEvent',
{
id: 'free',
title : 'Free Time',
start : freeTime[i].start,
end : freeTime[i].end
});
}
}
Could someone please give me an explanation? =)
Best regards,
James
I have had a similar issue and was able to resolve it by checking the following. The start and end times are not in the correct format, or all day event is defaulting to true.
allDay
true or false. Optional.
start
Date. Required.