欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

fullCalendar获取某一天的日程(event)

程序员文章站 2022-05-16 21:26:22
...

最近又是忙死的节奏。。。好久不做笔记,哎。最近的项目用到了fullCalendar这个插件,看了官方文档,确实是个很棒的插件,可以做到很多日历的事情。
官方API:
clientEvents

Retrieves events that FullCalendar has in memory.

.fullCalendar( ‘clientEvents’ [, idOrFilter ] ) -> Array
This method will return an array of Event Objects that FullCalendar has stored in client-side memory.

If idOrFilter is omitted, all events will be returned.

If idOrFilter is an ID, all events with the same ID will be returned.

idOrFilter may also be a filter function that accepts one Event Object argument and returns true if it should be included in the result set.

获取某天的event:

dayClick: function(date, jsEvent, view) {
        var events = $('#calendar').fullCalendar('clientEvents', function(event) {
            var eventStart = event.start;
            var eventEnd = event.end ? event.end : null;
            var theDate = date;
            // Make sure the event starts on or before date and ends afterward
            // Events that have no end date specified (null) end that day, so check if start = date
            return (eventStart <= theDate && (eventEnd >= theDate) && !(eventStart < theDate && (eventEnd == theDate))) || (eventStart == theDate && (eventEnd === null));
        });
        console.log(events); // do whatever with the console.log(events[0]._allDay); 
    }

这里只是dayclick的一个例子,可以在任何接口里使用,只要有date参数!