Full calendar get date from selected week

I am using FullCalendar (view of the week) plugin for jQuery in my project. In the FullCalendar week view, I see a string showing the date in the following format: Sunday 9/6, Monday 9/7, Tuesday 9/8, etc ...

var calendar = $('#calendar').fullCalendar({
    header: {
        left: 'prev',
        center: 'title',
        right: 'next'
    },
    defaultView: 'basicWeek'                    
});

      

Now I only used the title format in the calendar for the time sheet project. I want to get dates 9/6, 9/7 from the currently selected week in alert mode when going to the next / previous week (this is for the storage date in the database). Can I select dates separately for the current week?

+3


source to share


1 answer


You can get start and end dates from fullcalendar like this:

var currentDate = $('#calendar').fullCalendar('getDate');
var beginOfWeek = currentDate.startOf('week');
var endOfWeek = currentDate.endOf('week');

      

Edit:



You can add config events

for fullcalendar. This way you will get the start and end dates when you switch views, and you can also receive events and display them in the calendar.

events: function(start, end, callback){
    //request the back-end and call the callback when the ajax is done
    $.get('events/get', function(result){
        callback(result);
    });
}

      

+3


source







All Articles