事件发生后,Fullcalendar不会刷新

时间:2014-10-23 07:22:04

标签: javascript jquery fullcalendar

在fullcalendar中,添加事件时,如果用户在不刷新的情况下调整该事件的大小,则不会在数据库中更新修改。插入和修改工作正常。

这是我的插入代码

 $.ajax({
                           url: 'events.add.php',
                           data: 'start='+ copiedEventObject.start 
                           +'&end='+ copiedEventObject.end
                           +'&color='+ copiedEventObject.backgroundColor
                           +'&title='+ copiedEventObject.title
                           +'&cure_type='+ copiedEventObject.cure_type,
                           type: "POST",
                           success: function(json) {
                                location.reload(); 
// I wish not to use this refresh method because then I loose the location of the calendar. The calendar comes back to today's date.
                           }
                       });
 if ($('#drop-remove').is(':checked')) {
                            // if so, remove the element from the "Draggable Events" list
                            $(this).remove();
                        }   

这是我的更新代码

// load events from MySQL
                events:'events.json.php',

                // if event is moved around in the calendar
                eventDrop: function(event, delta) {
                    start = $.fullCalendar.formatDate(event.start, "yyyy-MM-dd HH:mm:ss");
                    end = $.fullCalendar.formatDate(event.end, "yyyy-MM-dd HH:mm:ss");
                    startTime = $.fullCalendar.formatDate(event.start, "Hmm");
                    $.ajax({
                    url: 'events.update.php',
                    data: 'start='+ start +'&end='+ end +'&id='+ event.id,
                    type: "POST",
                        success: function(json) {
                            //alert("Updated Successfully");
                        }
                    });
                },                  

                // if event is rezided in the calendar
                eventResize: function(event) {
                    start = $.fullCalendar.formatDate(event.start, "yyyy-MM-dd HH:mm:ss");
                    end = $.fullCalendar.formatDate(event.end, "yyyy-MM-dd HH:mm:ss");
                    $.ajax({
                    url: 'events.update.php',
                    data: 'start='+ start +'&end='+ end +'&id='+ event.id,
                    type: "POST",
                        success: function(json) {
                            //alert("Updated Successfully");
                        }
                    });
                }

1 个答案:

答案 0 :(得分:0)

我尝试过使用它,但它没有用。

 type: "POST",
                           success: function(json) {
                                //location.reload();                                
                                $('#calendar').fullCalendar('refetchEvents'); 
                           }

它会刷新页面,但它会复制我的活动...然后,如果我刷新页面,它就会起作用。