Javascript Fullcalendar-复制事件 [英] Javascript Fullcalendar - copying events

查看:298
本文介绍了Javascript Fullcalendar-复制事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目中使用Fullcalendar(http://arshaw.com/fullcalendar).它通过json源获取事件.

I'm using Fullcalendar (http://arshaw.com/fullcalendar) in my project. It gets events via json source.

我希望为用户提供将日历中的一个事件复制到另一天的选项-我想为此使用拖动(嗯,这是客户的要求).

I want to give the user option to copy one event on the calendar to other day - and I'd like to use dragging for that (well, that's the client's requirement).

但是拖动似乎是在移动事件,而不是复制事件-是否有任何方法可以获取被拖动事件的副本"(或将副本保留在原始位置),因此它看起来像是复制操作?

But dragging seems like moving an event, not copying - is there any way to get the "copy" of an event being dragged (or copy stay in original place), so it looks like a copy operation?

我试图在eventDragStart回调中复制事件对象,但是没有用.

I tried to copy event object in eventDragStart callback, but it didn't work.

推荐答案

下面是我的解决方案,它允许用户按住Shift键来复制事件. 请注意,这实际上是在移动原始事件,并将副本保留在原始位置.

Below is my solution that allows the user to hold shift key to copy events. Note that this is actually moving the original event and leaving a copy in the original position.

我从

I started with this reference and created the following:

//Before the fullCalendar object

    var copyKey = false;
    $(document).keydown(function (e) {
        copyKey = e.shiftKey;
    }).keyup(function () {
        copyKey = false;
    });

//then inside the fullCalendar object

    eventDragStart: function (event, jsEvent, ui, view) {
        if (!copyKey) return;
        var eClone = {
            title: event.title,
            start: event.start,
            end: event.end
        };
        $('#calendar').fullCalendar('renderEvent', eClone);
    },

这篇关于Javascript Fullcalendar-复制事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆