26

I work on a project that is based on the draggable events demo concept. I would like to be able to access the events data that has been collected as you add events to the calendar.

Is there a hook to access all the data that's been collected? I'm thinking something like:

$('#calendar').fullCalendar.getEvents();

I'd like to have a button call on the page outside of the calendar that gets all the data that has been collected and sends it back to the server as a string of JSON.

2 Answers 2

66
$('#calendar').fullCalendar('clientEvents');

Documentation

2
0

Use this code

$("#btnClear").click(function () {
        var events = $('#calendar').fullCalendar('clientEvents');
        for (var i = 0; i < events.length; i++) {
            var start_date = new Date(events[i].start._d);
            var end_date = '';
            if (events[i].end != null) {
                end_date = new Date(events[i].end._d);
            }
            var title = events[i].title;

            var st_day = start_date.getDate();
            var st_monthIndex = start_date.getMonth() + 1;
            var st_year = start_date.getFullYear();

            var en_day ='';
            var en_monthIndex = '';
            var en_year = '';
            if (end_date != '') {
                en_day = end_date.getDate()-1;
                en_monthIndex = end_date.getMonth()+1;
                en_year = end_date.getFullYear();
            }

            console.log('Title-'+title+', start Date-' + st_year + '-' + st_monthIndex + '-' + st_day + ' , End Date-' + en_year + '-' + en_monthIndex + '-' + en_day);
        }
    });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.