开发者

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

开发者 https://www.devze.com 2023-03-13 17:10 出处:网络
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 开发者_JAVA百科the \"freeTime\" array with all the Event o

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 开发者_JAVA百科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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消