php FullCalendar v5.x中eventAfterAllRender的替代选项

beq87vna  于 2023-04-19  发布在  PHP
关注(0)|答案(2)|浏览(102)

在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>

Codepen:https://codepen.io/wetruck/pen/poEXEve
在v5中加载所有事件后,是否有任何选项可以执行操作?
我实际上使用的是一个html加载器。它在页面加载时显示。但在加载所有事件后,它应该被删除。

xj3cbfub

xj3cbfub1#

对于这种情况,你有一个加载器,你想显示和隐藏,请参阅loading回调选项的东西,这将做的工作-你可以使用该回调使加载器显示/隐藏时, AJAX 部分的任务开始和停止。
例如

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

与旧的eventAfterAllRender不同,它在 AJAX 请求的开始/结束时启动和停止,并且不包括fullCalendar对事件的渲染,但这通常非常快,除非您在一个时间段内下载了大量的事件。

s5a0g9ez

s5a0g9ez2#

对于版本6,我使用下一个设置,而不是eventAfterAllRender

datesSet: function (dateInfo) {
  //my custom code                
}

相关问题