通过拖放完整日历来更新事件 - Javascript



我正在为我正在开发的项目使用 Fullcalendar ...我只剩下一个功能要实现,那就是将现有事件从其原始位置拖动到另一个时间或日期。我想知道我如何获取当前对象信息(标题、新开始时间、旧开始时间、id、url 等),以便我可以使用更新的信息更新数据库......我使用完整日历对象中的哪个属性?我实现了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();
            }
    },

但它没有做我想做的事...

查看事件拖动和调整大小 http://arshaw.com/fullcalendar/docs/event_ui/

我认为您正在寻找的事件丢弃回调。

拖动停靠点且事件已移动到其他停止点时触发 日/时间。

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();
        }
    }
});

相关内容

  • 没有找到相关文章