Andrew De Forest
Andrew De Forest

Reputation: 7338

Fullcalendar not rendering event

Using Fullcalendar on my website, I have a button that allows users to filter certain events. When they click a button to hide certain events, a function like this is fired:

var hidden_elements = [];

function toggle_hidden_events(toggle) {
    // remove events
    if(!toggle) {
        // Puts the event objects we're hiding into a global array, and also removes them from Fullcalendar (works fine)
        hidden_elements = hide_elements();
    }
    else {
        // does not work
        show_events(); // we dont pass the var since its global
    }
}

The first block, if(!toggle), works fine and hides the correct events and also assigns them to the array correctly.

However, when I call show_events(), it does not work as intended. Here is what the function looks like:

function show_events() {
    while(hidden_elements.length > 0) {
        var event = hidden_elements.pop();
        $("#calendar").fullCalendar('renderEvent', event, true);
    }
}

Using console.log(event), I have verified that valid event objects are being passed through to the renderEvent function. However, they are not showing up on the calendar.

Upvotes: 2

Views: 5721

Answers (1)

msapkal
msapkal

Reputation: 8346

Looks weird, I tried experimenting and found the same issue. An event object returned by the fullcalendar calendar was not show when we try to render it, however if we simplify the event object to it's basic properties or remove the "source" key the event get's rendered correctly.

    var myNewEvent = {
        "id": removedEvt.id,
            "title": removedEvt.title,
            "start": removedEvt.start,
            "end": removedEvt.end,
            "_id": removedEvt._id,
            "_start": removedEvt._start,
            "_end": removedEvt._end
        /*,
            "source" : removedEvt.source*/
    };

Following is the demo link, where in clicking toggle will toggle an event. If you uncomment the source key, event won't render. However _id, _start, _end is not mandatory as well.

DEMO

Hope this helps you.

Upvotes: 3

Related Questions