简体   繁体   English

事件删除后全日历不刷新

[英]Fullcalendar not refreshing after event drop

In fullcalendar, when an event is added, if the user resizes that event without refreshing, the modifications are not being updated in the database. 在全日历中,当添加事件时,如果用户调整该事件的大小而不刷新,则不会在数据库中更新修改。 Inserting and modifying is working perfectly. 插入和修改工作正常。

This is my insert code 这是我的插入代码

 $.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();
                        }   

This is my update code 这是我的更新代码

// 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");
                        }
                    });
                }

I tried using this, but it doesn't work. 我尝试使用此功能,但无效。

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

It does refresh the page, but it duplicates my event... then if I refresh the page, it works. 它的确刷新了页面,但是它复制了我的事件……然后,如果我刷新了页面,它就可以工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM