当事件源是对象属性时,fullcalendar removeEventSource不起作用 [英] fullcalendar removeEventSource not working when event source is object property

查看:677
本文介绍了当事件源是对象属性时,fullcalendar removeEventSource不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://jsfiddle.net/minlare/4G75c/

如果你看看上面的小提琴,我使用按钮添加/删除多个事件源。

If you take a look at the above fiddle I add/remove multiple event sources using buttons.

removeEventSource方法不起作用,并且重复点击切换按钮会导致添加重复的事件源。

removeEventSource method is not working and repeated clicks of the toggle buttons cause duplicate event sources to be added.

我已阅读说明具有相同对象引用的文档。
任何人都可以对此有所了解吗?

I have read the docs which explains having the same object reference. Can anyone shed any light on this?

    var target = $(e.target);
    if(this.types[target.data('type')].active){
        $('#calendar').fullCalendar('removeEventSource', this.types[target.data('type')].events);
    }else{
        $('#calendar').fullCalendar('addEventSource', this.types[target.data('type')].events);
    }


推荐答案

(截至本答复时)该问题似乎与添加事件源的方式有关;如果您检查代码,从 addEventSource 中调用的 buildEventSource 函数会在将源数据添加到日历之前转换源数据。 removeEventSource 函数不会逆转转换,因此找不到匹配,并且未删除事件源。

As of version 2.0.2 (current as of this reply) the issue appears to be related to the way event sources are added; if you examine the code, the buildEventSource function, which is called from within addEventSource, converts the source data before adding it to the calendar. The removeEventSource function does not reverse the conversion and, as a result, there is no match found and the event source is not removed.

I在两周前报告了一个相关的错误,但它仍然没有被接受。基本上,您的选择是自己挖掘代码并开发解决方法,或者等待解决问题的版本。我已经为我的具体情况制定了一个解决方法,但并不普遍;如果该错误在接下来的一周内不被接受,我会整合一个更持久(和普遍)的修复程序。

I reported a related bug two weeks ago but it still has not been accepted. Basically, your options are to dig into the code yourself and develop a workaround, or wait for a release that addresses the issue. I have incorporated a workaround for my specific situation but it is not universal; if the bug isn't accepted within the following week I will incorporate a more permanent (and universal) fix.

这篇关于当事件源是对象属性时,fullcalendar removeEventSource不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆