【问题标题】:updating an event by dragging/dropping fullcalendar- Javascript通过拖放 fullcalendar-Javascript 来更新事件
【发布时间】:2013-10-18 06:22:24
【问题描述】:

我正在将Fullcalendar 用于我正在开发的项目...我只剩下一个功能需要实现,即当现有事件从其原始位置拖到另一个时间或日期时。我想知道如何获取当前对象信息(标题、新开始时间、旧开始时间、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();
            }
    },

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

【问题讨论】:

    标签: javascript jquery fullcalendar


    【解决方案1】:

    看看 Event Dragging and Resizing 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();
            }
    
        }
    });
    

    【讨论】:

    • 嘿,我认为将外部事件拖到日历上时不会调用 eventDrop()。而是 drop() 函数。在我的情况下,外部事件会进入日历(在资源视图中),但它不会在那里显示,但是当我更改月份和周视图时,会显示相同的外部事件。所以我很困惑如何在 ResourceView 上带来同样的效果。
    • 有趣的@AffanPathan,你能在这里为你的问题添加一个小提琴吗?
    • 我错过了资源[] 属性,一旦我修复它,现在它工作正常。 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-26
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多