fullcalendar removeEventSource not working when event source is object property

旧城冷巷雨未停 提交于 2019-12-11 18:07:15

问题


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

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

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

回答1:


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 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.



来源:https://stackoverflow.com/questions/24829248/fullcalendar-removeeventsource-not-working-when-event-source-is-object-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!