5

プロジェクトで Fullcalendar (http://arshaw.com/fullcalendar) を使用しています。json ソース経由でイベントを取得します。

カレンダーの 1 つのイベントを別の日にコピーするオプションをユーザーに提供したいと思います。そのためにドラッグを使用したいと思います (まあ、それはクライアントの要件です)。

しかし、ドラッグはコピーではなくイベントを移動するように見えます-ドラッグされているイベントの「コピー」を取得する方法はありますか(またはコピーは元の場所にとどまります)、コピー操作のように見えますか?

eventDragStart コールバックでイベント オブジェクトをコピーしようとしましたが、うまくいきませんでした。

4

5 に答える 5

7

以下は、ユーザーがシフトキーを押してイベントをコピーできるようにする私のソリューションです。これは実際には元のイベントを移動し、コピーを元の位置に残すことに注意してください。

このリファレンスから始めて、次のように作成しました。

//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);
    },
于 2015-07-19T14:21:27.880 に答える
2

これを試して:

eventDrop: function(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view) {
    // Create an event object and copy at least the start date and the title from event
     var eventClone = {
         title:event.title,
         start: event.start,
         end: event.end
     };

     // Render new event with new event object
     $('#calendar').fullCalendar('renderEvent', eventClone);

     // Revert the changes in parent event. To move it back to original position
     revertFunc();
}

これは単なるアイデアです。このコードはテストしていません。仕組みを教えてください。ありがとう

于 2012-04-26T13:47:23.477 に答える