Jquery Fullcalendar和过滤事件的问题

时间:2011-08-25 11:55:25

标签: jquery fullcalendar

我有一个fullcalendar脚本在下拉列表中运行不同位置的事件过滤器。过滤器的工作方式是将请求的位置发送到服务器端脚本,然后返回该位置的事件列表。因此:

$('#calendar').livequery(function(){
var locationfilter = $('#locationfilter').val();
$(this).fullCalendar({
    header: {left: 'prev,next today',center: 'title',right: 'month'},
    defaultView:'month',
    editable: false,
       events: 'calendar_json.php?locationfilter='+locationfilter
});

$('#locationfilter').livequery('change',function(){
var locationfilter = $('#locationfilter').val();
$('#calendar').fullCalendar('removeEvents');
$('#calendar').fullCalendar('addEventSource', 'calendar_json.php?locationfilter='+locationfilter);
$('#calendar').fullCalendar('rerenderEvents');

    }); 

然而,我的问题是虽然这会很好地过滤事件,但当我更改月份时,它会为所有位置带回事件,而不仅仅是所选位置的事件。我尝试使用viewDisplay回调重新渲染,但这没有帮助,只是通过复制它们使问题变得更糟。

有关如何实现这一目标的任何想法?我有最新版本的fullcalendar,但我仍然在使用Jquery 1.3.2(出于多种原因,我不会进入)

2 个答案:

答案 0 :(得分:1)

http://code.google.com/p/fullcalendar/issues/detail?id=678

有一个解决方案,它涉及更改fullcalendar.js,但它对我很有用。

答案 1 :(得分:0)

我不确定我是否完全理解了这个问题,但是fullcalendar通过Json请求发送实际视图的开始和结束参数。

来自documentation about json feeds

的示例

说:/myfeed.php?start = 1262332800& end = 1265011200& _ = 1263178646其中start和end都是unix时间戳。如果我理解正确,那么你想在你的php文件中使用它来发送只在开始和结束之间的事件。然后必须删除livequery。