简体   繁体   English

FullCalendar单击并拖动多个事件

[英]FullCalendar click and drag multiple events

I'm trying to set up a calendar where a user can select multiple time slots by clicking and dragging in the weekly view ('agendaWeek'). 我正在尝试设置一个日历,用户可以通过单击并在每周视图(agendaWeek)中拖动来选择多个时隙。 For example - Mon 2-4pm, Tues 1:30-2:00pm, etc. 例如-星期一2-4pm,星期二1:30-2:00pm等

What's the recommended way to do this? 推荐的方法是什么? Currently every time a new selection is made, the previous one automatically gets cleared. 当前,每次进行新选择时,上一个都会自动清除。

Everytime a user selects a timerange, it creates a kind of placeholder event for visual feedback to the user. 每次用户选择时间范围时,都会创建一种占位符事件,以向用户提供视觉反馈。 This isn't actually an event yet, and it is removed when the user makes another selection. 这实际上还不是一个事件,当用户进行其他选择时将其删除。

What you need to do, is add an actual event whenever a selection is made. 您需要做的就是在做出选择时添加一个实际事件。

Use the select callback . 使用select回调

It's triggered every time the user selects (clicks and drags) a time slot. 每当用户选择(单击和拖动)一个时隙时,就会触发该事件。 In it, call addEventSource to add it to the calendar as an actual event. 在其中,调用addEventSource将其作为实际事件添加到日历中。 And then call unselect to manually remove the placeholder. 然后调用unselect手动删除占位符。

select: function (start, end, jsEvent, view) {
    $("#calendar").fullCalendar('addEventSource', [{
        start: start,
        end: end,
    }, ]);
    $("#calendar").fullCalendar("unselect");
}

JSFiddle 的jsfiddle

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

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