从FullCalendar(jQuery)中移除事件源的问题 [英] Problem removing event sources from FullCalendar (jQuery)

查看:112
本文介绍了从FullCalendar(jQuery)中移除事件源的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

然后,我使用 FullCalendar 显示来自多个来源的事件,一些本地JSON订阅源,以及其他Google日历。我已经实现了一个功能,通过该功能,可以在复选框分别为true或false时显示/隐藏单个日历。



我使用以下代码实现它:

  $('#calendar_list input','#sidebar')。live('click',function(){$ b $ ($(this).is(:checked)== true){
//显示日历
var source = $ .fullCalendar.gcalFeed(http://www.google .com / calendar / feeds / usa__en%40holiday.calendar.google.com / public / basic);
$('#calendar')。fullCalendar('addEventSource',source);
} else {
//移除日历
var source = $ .fullCalendar.gcalFeed(http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/基本);
$('#calendar')。fullCalendar('removeEventSource',source);
}
});

这个例子如果只显示/隐藏Google日历Feed,问题是它永远不会隐藏日历再次...如果我点击复选框10次,(1 =关,2 =开,3 =关,4 =开等),它显示相同日历的5个版本。



文档似乎没有提供很多线索,它似乎这个问题已经在Google Project网站上为这个项目惹上了一些麻烦。



如何删除事件源? *哭泣*



任何帮助,将不胜感激。

解决方案

那么,我已经找到了解决问题的方法,我决定回顾一下Google Project的问题,并注意到对于我遇到的同样的问题,文档说明:
$ b


源必须是对原始Array / URL / Function的引用。


我认为这意味着删除日历,我必须使用相同的日历源添加到我添加的,所以如果我添加源 /getEvents.php 我必须以相同的方式删除它,而实际上它意味着我必须使用完全相同的源代码。

因此,我将源设置为数组中的项目(日历ID为键),然后我可以基于这,现在已经解决了这个问题。


Right then, I'm using FullCalendar to display events from multiple sources, some local JSON feeds, others from Google Calendar. I've implemented a feature whereby a single calendar can be displayed / hidden when it's checkbox is true or false respectively.

I'm using this code to achive it:

$('#calendar_list input','#sidebar').live('click', function() {
    if($(this).is(":checked")==true) {
        // display the calendar     
        var source = $.fullCalendar.gcalFeed("http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic");
        $('#calendar').fullCalendar('addEventSource', source);
    } else {
        // remove the calendar
        var source = $.fullCalendar.gcalFeed("http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic");
        $('#calendar').fullCalendar('removeEventSource', source);
    }
});

This example if just to show / hide a Google Calendar feed, the problem is it never hides the calendar again... if I click the check box 10 times, (1=off, 2=on, 3=off, 4=on etc) it displays 5 versions of the same calendar.

The documentation doesn't really seem to give many clues and it seems this problem has plauged a few on the Google Project site for the project.

How to I remove an event souce?! *cries*

Any help would be appreciated.

解决方案

Right then, I've actually found the solution to my problem, I decided to look back over the Google Project issues and noticed that someone had raised an issue for the same problem I was having, now the documentation says:

Source must be a reference to the original Array/URL/Function. Events from the source will immediately be removed from the calendar.

I thought this meant to remove a calendar I would have to use an identical source to the one I added, so if I added source /getEvents.php I would have to remove it in the same way, instead what it actually means is that I have to use the exact same source.

So I set the source as an item in an array (calendar id as the key) and then I can add / remove the calendar based on this, this has now solved the problem.

这篇关于从FullCalendar(jQuery)中移除事件源的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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