繁体   English   中英

如何将fullcalendar事件限制为仅一天?

[英]How to limit fullcalendar events to only one day?

是否可以限制FullCalendar,因此在创建事件拖动时,事件不会在其他日子发生?

我的意思是:如果我在3月20日09:00开始选择,我希望用户不能选择在3月21日13:00结束的活动。

您可以将eventConstraint添加到日历设置中。

eventConstraint:{
          start: '00:00', // a start time (start of the day in this example)
          end: '24:00', // an end time (end of the day in this example)
        }, 

你可以在这个plunker中重现它。

如果你想在拖动期间限制它,我想你只能使用eventDrop回调来做它。 如果moment.startOf('day)不同,您可以使用revertFunc将拖放动作恢复到之前的状态。

就像是:

$('#calendar').fullCalendar({
    events: [
        // events here
    ],
    editable: true,
    eventDrop: function(event, delta, revertFunc) {

        if (!event.start.startOf('day').isSame(event.end.startOf('day'))) {
             revertFunc();
        }
    }
});
$('#calendar').fullCalendar({
events: [
    {
        title  : 'event1',
        start  : '2010-01-01'
    },
    {
        title  : 'event2',
        start  : '2010-01-09T09:30:00',
        end    : '2010-01-09T15:30:00',
    },
    {
        title  : 'event3',
        start  : '2010-01-09T12:30:00',
        allDay : false // will make the time show
    }
]

});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM