7

開発中のプロジェクトにFullcalendarを使用しています ... 実装する機能が 1 つだけ残っています。それは、既存のイベントを元の位置から別の時間または日付にドラッグする場合です。現在のオブジェクト情報 (タイトル、新しい開始時刻、古い開始時刻、ID、URL など) を取得する方法を知りたいので、新しい情報でデータベースを更新できます... Fullcalendar オブジェクトのどのプロパティが行うか私が使う?dropプロパティを実装しました。

    drop  : function(date, allDay) {
            // retrieve the dropped element's stored event object
            var originalEventObject = $(this).data('eventObject');
            // we need to copy it, so that multiple events don't 
            // have a reference object
            var copiedEventObject   = $.extend({}, originalEventObject);
            // assign it the date that was reported
            copiedEventObject.start = date;
            copiedEventObject.allDay = allDay;

            // render the event on the calendar
            // the last `true` argument determines if the event `sticks`
            $('#calendar').fullCalendar('renderEvent', copiedEventObject, true);

            // if the 'remove after drop' checkbox checked?
            if ($('#drop-remove').is(':checked')) {
                // if so remove the element from the "Draggable Events"
                $(this).remove();
            }
    },

しかし、それは私が望んでいたことをしていません...

4

1 に答える 1

15

イベントのドラッグとサイズ変更http://arshaw.com/fullcalendar/docs/event_ui/をご覧ください。

eventDropコールバックを探していると思います。

ドラッグが停止し、イベントが別の日時に移動したときにトリガーされます。

http://arshaw.com/fullcalendar/docs/event_ui/eventDrop/

arshaw のサイトからの例:

$('#calendar').fullCalendar({
    events: [
        // events here
    ],
    editable: true,
    eventDrop: function(event,dayDelta,minuteDelta,allDay,revertFunc) {

        alert(
            event.title + " was moved " +
            dayDelta + " days and " +
            minuteDelta + " minutes."
        );

        if (allDay) {
            alert("Event is now all-day");
        }else{
            alert("Event has a time-of-day");
        }

        if (!confirm("Are you sure about this change?")) {
            revertFunc();
        }

    }
});
于 2013-10-17T22:22:24.053 に答える