Fullcalendar - 在月视图中将天数限制为单日全天活动

时间:2011-03-30 17:52:52

标签: jquery-plugins fullcalendar

是否可以在月视图中将一天限制为单日全天活动?理想情况下,这将处理各个日期选择以及日期范围。

1 个答案:

答案 0 :(得分:0)

肯定有更好的方法可以做到这一点,但这是我暂时想出来的。我希望能够在不必循环所有事件的情况下完成此任务。

select: function (newEvent_start, newEvent_end, allDay) {
                var okToAdd = true;
                $('#calendar').fullCalendar('clientEvents', function (event) {
                    if ( (newEvent_start >= event.start && newEvent_end <= event.end) || // between
                         (newEvent_start <= event.start && newEvent_end >= event.start) || // starts before, ends during
                         (newEvent_start >= event.start && newEvent_start <= event.end && newEvent_end >= event.end)  // starts during, ends after
                       )
                        okToAdd = false;
                });

                if (okToAdd) {
                    calendar.fullCalendar('renderEvent',
                    {
                        title: 'Title goes here',
                        start: newEvent_start,
                        end: newEvent_end,
                        allDay: allDay
                    },
                    true 
                );
                }
                calendar.fullCalendar('unselect');
            }