Mr.J4mes
Mr.J4mes

Reputation: 9266

jQuery FullCalendar: failed to render event using renderEvent() method

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

Upvotes: 2

Views: 3749

Answers (1)

drneel
drneel

Reputation: 2907

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.

When specifying Event Objects for events or eventSources, omitting this property will make it inherit from allDayDefault, which is normally true.

start Date. Required.

When specifying Event Objects for events or eventSources, you may specify a string in IETF format (ex: "Wed, 18 Oct 2009 13:00:00 EST"), a string in ISO8601 format (ex: "2009-11-05T13:15:30Z") or a UNIX timestamp.

Upvotes: 3

Related Questions