2
votes

I am using fullcalendar(v2.0.0) in my application. All events displaying from DB and user can drag and drop and updates events. Everything working fine except that dropped event again goes to old date when click on fullcalendar's next/prev button.

check my fiddle 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'}]

});

The exact problem is if i drag and dropped Plants event to 2015-05-20 then it moved to 2015-05-20 but if i click next/prev then again that moved event go back to 2015-05-18.

Why this happen? How to fix this?

1

1 Answers

3
votes

you need to write your calendar's drop event callback in which you will send the new date to server and server will update the date of event in db so next time it will come with updated date as follow

$('#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();
                        }
                    }
                });
            },
});