完整日历使用数据库中的外部事件删除编辑描述

Full calendar Drop edit description with the external events from database

在完整日历外部拖动事件中,我想通过在复制事件时添加插入数据库中的事件 ID 和描述来更改描述。

 droppable: true, // this allows things to be dropped onto the calendar !!!
                drop: function(date, allDay){ // this function is called when something is dropped
                    // 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 to the same object
                    var copiedEventObject = $.extend({}, originalEventObject);
                    // assign it the date that was reported
                    copiedEventObject.start = date;
                    copiedEventObject.description = 'custom_event';
                    copiedEventObject.allDay = allDay;
                    copiedEventObject.className = $(this).attr("data-class");
                    var new_date = copiedEventObject.start.format();
                    var new_event = copiedEventObject.title;
                    $.post('calendar_action.php',{'action':'create_event','date':new_date,'event':new_event},function(data){
                       $(copiedEventObject).attr("description",data);
                    });
// render the event on the calendar the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)
                    $('#calendar').fullCalendar('renderEvent', copiedEventObject, true);
                    $(this).remove();

                },

ajax 中的 $.post 方法没有传递全局变量,所以我使用了 $.ajax 方法并且工作正常

$.ajax({
                        type: 'POST',
                        async: false,
                        url: "calendar_action.php",
                        data: {'action':'create_event','date':new_date,'event':new_event},
                        success: function(data) {
                            desc = data;
                        }
                    });
                    copiedEventObject.description = desc+'_custom_event';