Muhammad Adeel Zahid Muhammad Adeel Zahid - 2 years ago 469
jQuery Question

Adding events to events array returned from server FullCalendar

I am using fullcalendar to render events in my web application. I am getting the json feed of events from server using following method

events: {
url: '/api/availability/events',
error: function () {
//alert("some error fetching events");

The events are returned and rendered fine by the full calendar and here is the view of those events in the calendar.
Current View of Full Calendar

The requirement is to show a default event on each day for which server has not returned any event. Like, I want to display event on each empty cell with title
Available for All meals
. And the requirement is that this should be done on client side and server should not know anything about the default event. So my question is how I can change the events array after it is returned from the server and add a default event for each empty day

where empty day = a day with no events


Answer Source

I ended up using the following method from fullcalendar documentation

    events: function(start, end, timezone, callback) {
            url: 'myxmlfeed.php',
            dataType: 'xml',
            data: {
                // our hypothetical feed requires UNIX timestamps
                start: start.unix(),
                end: end.unix()
            success: function(doc) {
                var events = [];
                $(doc).find('event').each(function() {
                        title: $(this).attr('title'),
                        start: $(this).attr('start') // will be parsed
                //append custom events here
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download