Skip to content Skip to sidebar Skip to footer

Fullcalendar 4, Callback When Calendar Is Completely Rendered

Fullcalendar version 3 used to have a callback function that would fire once all events have rendered. I would use this: eventAfterAllRender: function( view ) { load_call_lis

Solution 1:

Ok, so how about this? I can use the loading function. When the calendar is done loading, I can call my load_call_list function. I am using a bool variable to stop it from firing everytime the calendar loads without a page refresh (like when cycling through months or weeks, for instance).

When the page first loads, I have a var called initial_load = true. When the calendar has finished 'loading', if this is true, then I'll call my function and set my initial_load to false so it won't just fire off as I explained before.

<script>
//set initial_load so when the calendar is done loading, it'll get call list infovar initial_load = true;

document.addEventListener('DOMContentLoaded', function() {


    var calendar1 = document.getElementById('calendar_mini');
    var calendar_mini = new FullCalendar.Calendar(calendar1, {
       ....
       ....
       loading: function(bool) {

        if (bool) {
            $('.loader').show();
            $('#show_cancelled_appts').hide();
            $('#show_rescheduled_appts').hide();
            $('#print_calendar').hide();
        } else {
            $('.loader').hide();
            $('#show_cancelled_appts').show();
            $('#show_rescheduled_appts').show();
            $('#print_calendar').show();

            //once it's done loading, load call list with current date stuff; set 
            initial_load = false so it doesn't keep loading call list when calendar changes while cycling months/weeks/etc
                var today = moment().format('YYYY-MM-DD');
                if (initial_load) {
                    load_call_list(today);
                    initial_load = false;
                }


        }
 },

It does actually work! Thoughts on that? Is this okay programming? I don't see any downside as of now.

Post a Comment for "Fullcalendar 4, Callback When Calendar Is Completely Rendered"