0

I setup my fullCalendar instance to get events from a function.

It works if I hardcode the dates, but how do I wire up the navigational buttons to go back and forth between months?

It doesn't pass any parameters and I can't think of how to make this work.

Here is where I call fullCalendar:

   var calendar = $('#calendar').fullCalendar({
        events: getCalendarEvents  //events as a function
});

This is the function it uses:

var lastDayofLastMonth = '8-31-2014'
    var lastDayofCurrentMonth = '9-30-2014'

    var getCalendarEvents = (function (start, end, timezone, callback) {
        return $.ajax("/api/events/" + lastDayofLastMonth + "/" + lastDayofCurrentMonth, {
            type: "GET",
            contentType: "application/json",
            success: function(response, status, XHR) {
                var calObj = [];
                $.each(response, function (index, item) {
                    var evt = {
                        title: item.title,
                        start: item.startDateTime,
                        end: item.endDateTime
                    };
                    calObj.push(evt);
                });
                callback(calObj);
            }
        });

    });

Thanks

SkyeBoniwell
  • 6,345
  • 12
  • 81
  • 185

1 Answers1

0

You can try this

Keep variables that hold the current month and last month dates on button click , update the current month and last month dates depending on the button clicked and pass those to get the data.

If you need help to get the date manipulation , look at this link

Get first and last date of current month with javascript or jquery

Community
  • 1
  • 1
user3700866
  • 151
  • 1
  • 9