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

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

    I've just come across this issue myself whilst finding a solution for entering public holidays on to a calendar. I found this to be a good solution for full day events. I hope this can help someone else further down the line.

    $('#calendar').fullCalendar({                
        eventClick: function (event) {
            ShowEditScreen(event.id);
        },
        dayClick: function (date) {
            var events = $('#calendar').fullCalendar('clientEvents');
            for (var i = 0; i < events.length; i++) {
                if (moment(date).isSame(moment(events[i].start))) {
                    ShowEditScreen(events[i].id);
                    break;
                }
                else if (i == events.length - 1) {
                    ShowCreateNew(date);
                }
            }
        }
    });
    

提交回复
热议问题