FullCalendar 中 eventAfterAllRender 的替代选项 v5.x

Alternative option for eventAfterAllRender in FullCalendar v5.x

在 FullCalendar v3 中,有一个选项可以在加载所有事件后进行捕捉。

eventAfterAllRender

它似乎在 v4 中被删除了。正如这里所说: https://fullcalendar.io/docs/v4/upgrading-from-v3

这里有一段代码可以在 v5 中准备演示日历。

<!DOCTYPE html>
<html>
    <head>
        <meta charset='utf-8' />
        <link href='https://cdn.jsdelivr.net/npm/fullcalendar@5.5.1/main.min.css' rel='stylesheet' />
        <script src='https://cdn.jsdelivr.net/npm/fullcalendar@5.5.1/main.min.js'></script>
        <script>

            document.addEventListener('DOMContentLoaded', function () {
                var calendarEl = document.getElementById('calendar');

                var calendar = new FullCalendar.Calendar(calendarEl, {
                    headerToolbar: {
                        left: 'prev,next today',
                        center: 'title',
                        right: 'dayGridMonth,timeGridWeek,timeGridDay,listMonth'
                    },
                    initialDate: '2020-09-12',
                    navLinks: true, // can click day/week names to navigate views
                    businessHours: true, // display business hours
                    editable: true,
                    selectable: true,
                    events: [
                        {
                            title: 'Business Lunch',
                            start: '2020-09-03T13:00:00',
                            constraint: 'businessHours'
                        },
                        {
                            title: 'Meeting',
                            start: '2020-09-13T11:00:00',
                            constraint: 'availableForMeeting', // defined below
                            color: '#257e4a'
                        },
                        {
                            title: 'Conference',
                            start: '2020-09-18',
                            end: '2020-09-20'
                        },
                        {
                            title: 'Party',
                            start: '2020-09-29T20:00:00'
                        },

                        // areas where "Meeting" must be dropped
                        {
                            groupId: 'availableForMeeting',
                            start: '2020-09-11T10:00:00',
                            end: '2020-09-11T16:00:00',
                            display: 'background'
                        },
                        {
                            groupId: 'availableForMeeting',
                            start: '2020-09-13T10:00:00',
                            end: '2020-09-13T16:00:00',
                            display: 'background'
                        },

                        // red areas where no events can be dropped
                        {
                            start: '2020-09-24',
                            end: '2020-09-28',
                            overlap: false,
                            display: 'background',
                            color: '#ff9f89'
                        },
                        {
                            start: '2020-09-06',
                            end: '2020-09-08',
                            overlap: false,
                            display: 'background',
                            color: '#ff9f89'
                        }
                    ]
                });

                calendar.render();
            });

        </script>
        <style>

            body {
                margin: 40px 10px;
                padding: 0;
                font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
                font-size: 14px;
            }

            #calendar {
                max-width: 1100px;
                margin: 0 auto;
            }

        </style>
    </head>
    <body>

        <div id='calendar'></div>

    </body>
</html>

代码笔:https://codepen.io/wetruck/pen/poEXEve

是否有任何选项可以在加载 v5 中的所有事件后执行操作?

我实际上使用的是 html 加载器。它随页面加载一起显示。但是在加载所有事件后,应该将其删除。

对于您想要显示和隐藏加载程序的这种情况,请查看 loading 回调选项以了解可以完成这项工作的内容 - 您可以使用该回调来制作加载程序 show/hide 当 AJAX 部分任务开始和停止时。

例如

loading: function( isLoading ) {
  if (isLoading == true) {
    //show your loader
  } else {
    //hide your loader
  }
}

与旧的 eventAfterAllRender 不同,它在 AJAX 请求的 start/end 开始和停止,并且不包括 fullCalendar 事件的呈现,但这通常非常快除非您在一个时间段内下载的事件数量多得离谱。