FULLCALENDAR-移动事件再次恢复到旧日期,当单击prev/下一个



我在应用程序中使用了fullcalendar(v2.0.0)。从数据库和用户显示的所有事件都可以拖放和更新事件。一切正常,除了删除事件再次到达旧日期时,当单击FullCalendar的Next/prev按钮时。

检查我的小提琴http://jsfiddle.net/manivasagam/3e8nk/1021/

$('#calendar').fullCalendar({
events:"/FullcalendarProject/FullCalendarChecking" 
  // my events will be like this from DB [{title: 'Plants',start: '2015-05-18'}, {title: 'Animals',start: '2015-05-23'}]
});

确切的问题是,如果我拖动 plants 事件到2015-05-20,则它移至2015-05-20,但是如果我单击Next/prev到2015-05-18。

为什么会发生这种情况?如何解决此问题?

您需要编写日历的Drop Event回调,您将将新日期发送到服务器,服务器将在DB中更新事件日期,因此下次它将随附更新日期为关注

$('#calendar').fullCalendar({
events:"/FullcalendarProject/FullCalendarChecking" ,
  // my events will be like this from DB [{title: 'Plants',start: '2015-05-18'}, {title: 'Animals',start: '2015-05-23'}]
eventDrop: function (event, delta, minuteDelta, allDay, revertFunc) {
                console.log(event);
//asking for confirmation from user using $.prompt you can skip and send direct ajax
                $.prompt("Are you sure you want to move the events "+delta+" days?", {
                    title: "Are you Sure?",
                    buttons: { "Yes": true, "No": false },
                    submit: function (e, v, m, f) {
                        // use e.preventDefault() to prevent closing when needed or return false.
                        // e.preventDefault();
                        if (v)
                        {
                            $.ajax({
                                url: "/modules/crm_events/support/changeEventDate.php",
                                data: { id: event.id, changeDays: delta , table:event.className[2] , part:event.part },
                                type: "GET",
                                dataType: "json",
                            }).done(function (data) {
                            });
                        }
                        else
                        {
                            revertFunc();
                        }
                    }
                });
            },
});

最新更新