In the FullCalendar dayClick event, can I get the events that already exist in clicked date?

前端 未结 5 1335
陌清茗
陌清茗 2020-12-14 04:34

In the FullCalendar dayClick event, can I get the events that already exist in clicked date?

http://arshaw.com/fullcalendar/docs/mouse/dayClick/

Let me expla

5条回答
  •  独厮守ぢ
    2020-12-14 05:15

    This is is you need all your events for the current day in another function:

                var date = $('.js-calendar').fullCalendar('getDate');
                date = date.toDate();
                var startDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
                var endDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59);
                var todaysEvents = $('.js-calendar').fullCalendar('clientEvents', function(event) {
                    if (event.start.toDate() >= startDate && event.start.toDate() <= endDate
                        || event.end.toDate() >= startDate && event.end.toDate() <= endDate) {
                        return true
                    }
                });
    

提交回复
热议问题