How to send intervalStart/End to ajax-File with fullcalendar

44 Views Asked by At

i use fullcalendar and have following problem: My ajax_load_projektkalender.php does not get the correct sel_jahr / sel_monat value as the value of cal_enddatum is not correct (especially when browsing to the previous / next month)

But on the other hand "cal_enddatum_test" is correct so it seems that intervalEnd is not loaded yet when the ajax-file is called (which seems logically).

So how can i get the correct intervalEnd PRIOR to calling the ajax-file?

Here is my code:

$(document).ready(function() {
    $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay,listWeek'
        },
        defaultDate: defDate_str,
        firstDay: 1, 
        navLinks: true,
        selectable: true,
        selectHelper: true,
        
        editable: false,
        eventLimit: true,

        events: {
            url: 'ajax_load_projektkalender.php',
            type: 'POST',
            data: function() {
                var cal_enddatum = $('#calendar').fullCalendar('getView').intervalEnd
                
                var sel_jahr = (cal_enddatum?cal_enddatum:moment()).format('Y')
                var sel_monat = (cal_enddatum?cal_enddatum:moment()).format('M')

                return {
                    sel_jahr : sel_jahr ,
                    sel_monat : sel_monat
                };
            },
            error: function() {
                alert('there was an error while fetching events!');
            },
            color: 'yellow',   // a non-ajax option
            textColor: 'black' // a non-ajax option
        },
        displayEventEnd: {
                        month: false,
                        basicWeek: true,
                        "default": true
                    }, 
        timeFormat: 'H:mm', // uppercase H for 24-hour clock
        eventAfterAllRender: function(view) {
            var cal_enddatum_test = view.intervalEnd;
        }
    });
});

Thank you for support.

Daniel

0

There are 0 best solutions below