【问题标题】:How can I add an event inside an other event - fullcalendar如何在另一个事件中添加一个事件 - fullcalendar
【发布时间】:2016-07-01 21:49:57
【问题描述】:

我尝试基于 AngularJS 创建一个名册。对于这个项目,我使用的是 fullcalendar(调度程序版本)。

这是我目前的状态:

最终目标是,我想将员工拖放到工作层中。例如,“Haris Bjelic”,在我的工作层中(显示为“WL from 01.06 - 04.06”)。

然后我知道“Haris Bjelic”需要从 01.06 到 04.06 工作(没有任何休息,呵呵)。首先,我试图找到一个函数,它可以让我在另一个事件中添加一个事件。在这种情况下,我首先从 01.06 创建了一个名为“工作层”的层。 - 04.06' 我可以在此层中拖放任何员工,以规划他们的工作时间。

在调度程序的左侧列出了我的部门(如酒吧、服务等)。右侧是可见的接下来的几天。

目前我尝试了这个功能:

eventOverlap: function(stillEvent, movingEvent) {}

因此,如果我将“haris bjelic”拖放到“WL from 01.06 - 04.06”中,如果它们重叠在一起,我就可以访问这两个事件。因此,我尝试获取“可拖动”事件的 ID 和“WL from 01.06 - 04.06”的 ID,以将其设置为数据库的关系。

如果这样做了,我想将员工姓名附加到工作层的“标题”。如果我将“Haris Bjelic”和其他员工拖放到“WL from 01.06 - 04.06”,结果需要如下所示:

'WL 01.06 - 04.06
  "Haris Bjelic"
  "Foo Employe"
  2 emplyoee are working in this Layer'

这是我想要的结果!

使用 eventOverlap 函数,我可以访问这两个事件。目前,当我将“haris bjelic”拖到另一个事件并触发了重叠功能时,我想更改工作层的标题。

在 eventOverlap 里面我试过这个:

stillEvent.text += "\n" + movingEvent.text;
element.fullCalendar('updateEvent', stillEvent);

它创建了一个新事件来仅更改文本!

看这里:

为什么 updateEvent 会创建一个新的 Event 而不是更新旧的事件?我把 stillEvent 放在 updateEvent 函数中。

【问题讨论】:

    标签: javascript angularjs events fullcalendar fullcalendar-scheduler


    【解决方案1】:

    事件中没有text 属性,它是title。更新标题后,我还使用此代码从日历中删除movingEvent:

            eventOverlap: function(stillEvent, movingEvent) {
                stillEvent.title += "\n" + movingEvent.title;
                $('#calendar').fullCalendar('updateEvent', stillEvent);
                $('#calendar').fullCalendar('removeEvents', movingEvent._id);
                return false;
            },
    
            eventReceive: function(event) { // called when a proper external event is dropped
                $('#calendar').fullCalendar('removeEvents', event._id);
            },
    

    此代码适用于与 fullCalendar 捆绑的外部拖动演示。

    【讨论】:

    • 嗨 K48!抱歉,我整个星期都病得很重,无法编程或工作。我已经检查了你的解决方案,它对我来说很好用!非常感谢!
    猜你喜欢
    • 2013-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多