fullcalendar - 在eventRender之后删除已删除的事件

时间:2015-01-20 10:01:25

标签: fullcalendar

我想使用fullcalendar向数据库添加事件,我已经成功完成了我的方法。但是,在日历中呈现事件后,有两个类似的事件。一个已被删除,另一个已在成功的ajax请求后呈现。

这是代码

drop: function(date, event) {
            var title = event.target.textContent;
            var start = date.format();
            $.ajax({
                url: 'process.php',
                data: 'type=new&title='+title+'&startdate='+start,
                type: 'POST',
                dataType: 'json',
                async: false,
                success: function(response){
                    $('#calendar').fullCalendar('renderEvent',response.eventblock,false);
                },
                error: function(e){
                    console.log(e.responseText);
                }
            });
            console.log(event);
        }

在成功块中,我使用了renderEvent将事件添加到日历中。成功执行ajax请求后如何删除已删除的事件?

1 个答案:

答案 0 :(得分:0)

首先,不建议您添加事件的方式。基本上,您正在添加无源事件,这意味着您必须手动处理所有自动事件。

但也许你有理由,idk。

要使其有效,请提供您的活动ID,然后使用removeEvents来"删除"添加一个具有相同身份http://fullcalendar.io/docs/event_data/removeEvents/

的人时
success: function(response){
    $('#calendar').fullCalendar(
        'removeEvents', response.eventblock.id //or something like that
    );
    $('#calendar').fullCalendar(
        'renderEvent', response.eventblock, false
    );
}
相关问题