Fullcalendar活动限制和资源

时间:2017-06-22 07:05:10

标签: javascript jquery fullcalendar fullcalendar-scheduler

我正在尝试this demo in jsbin与调度程序有一些事件,并限制将其中的一些事件移动到特定资源。

$('#calendar').fullCalendar({
    schedulerLicenseKey: "CC-Attribution-NonCommercial-NoDerivatives",
    // put your options and callbacks here
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,basicWeek,agendaDay'
    },
    defaultView: 'agendaDay',
    defaultDate: '2017-05-09',
    navLinks: true, // can click day/week names to navigate views
    editable: true,
    nowIndicator: true,
    allDaySlot: false,
    fixedWeekCount: false,
    eventLimit: true, // allow "more" link when too many events
    slotLabelFormat: "HH:mm",
    slotLabelInterval: "00:60:00",
    events: [
        {
            title: 'Long Event',
            start: '2017-05-09T16:00:00',
            end: '2017-05-09T17:00:00',
            resourceId: 'b',
            constraint: {
                resourceIds: ['c', 'd']
            }
        },
        {
            id: 999,
            title: 'Test Event',
            start: '2017-05-09T16:00:00',
            end: '2017-05-09T18:00:00',
            resourceId: 'a',
            constraint: {
                resourceIds: ['b', 'c', 'd']
            }
        }
    ],
    resources: [
        {id: 'a', title: 'Auditorium A'},
        {id: 'b', title: 'Auditorium B'},
        {id: 'c', title: 'Auditorium C'},
        {id: 'd', title: 'Auditorium D'}
    ]
})

现在,如果按照here说明进行操作,您会注意到在resourcesIds中指定了您希望事件不要去的ID。但是在jsbin中你可以看到相反的情况正在发生。

此外,如果您打开月视图或周视图,则无法从一天拖放到另一天。由于eventConstraint而限制你。

我做错了什么或这是不是有问题?

暂时解决此解决方案的问题,但我认为以上是一个错误。您可以尝试my solution here

我所做的是在事件的自定义字段中传递约束,并检查丢弃是否正确。

1 个答案:

答案 0 :(得分:1)

  

现在,如果您按照此处的说明进行操作,您会发现内部情况   您指定了不希望事件发生的ID的resourcesIds   去。

不,文章恰恰相反:

  

可以应用其他属性强制事件保持在之内   具体资源

(我加了粗体。)

这意味着您提供可以拖动事件的资源列表。因此,它不能拖动到约束属性中未命名的任何资源。

根据您发布的链接中提供的示例:

constraint: {
  resourceIds: [ 'a', 'b', 'c' ] // constrain dragging to these
}

只允许将具有此属性的事件拖到资源'a','b'和'c'上。

我认为您误解了文档。