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

前端 未结 5 1338
陌清茗
陌清茗 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:17

    Exested answers didn't work for me so there is working code:

    dayClick: function (date, jsEvent, view) {
        var count = 0;
    
        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);
    
        $('#calendar').fullCalendar('clientEvents', function (event) {
                if (event.start.toDate() >= startDate && event.start.toDate() <= endDate
                    || event.end.toDate() >= startDate && event.end.toDate() <= endDate) {
                            count++;
                        }
                    });
        //count - number of events on this day
    }
    

提交回复
热议问题