完整日历 删除数据库中外部事件的编辑说明



在完整日历外部拖动事件中,我想通过在复制事件时添加插入数据库中的事件的 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';  

相关内容

  • 没有找到相关文章

最新更新