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

最近又是忙死的節奏。。。好久不做筆記,哎。最近的項目用到了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參數!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章