2

我在使用 fullCalendar 的页面中有以下代码。我可以在我的页面中添加事件,但是日历不会动态显示。在显示我添加的日期之前,我必须移动到另一个月(然后回到当前月)。

有没有办法在以编程方式添加日期时动态刷新/渲染日历?

到目前为止,这是我的代码片段:

## the code for generating the calendar

<script>

$(document).ready(function() {



 $('#calendar').fullCalendar({

  editable: false,

  events: 'http://example.com/getevents.php',

 });

});

</script> 

<h1>Calendar Test</h1>

<div id='calendar'></div>





## the code for updating it

$('#calendar').fullCalendar( 'refetchEvents' );
4

2 回答 2

1

kyle is using something like $calendar=$('#some_div').fullCalendar(...) in order to minimize the number of DOM parsings performed by jQuery for finding the div. This is a common jQuery optimization.

于 2010-06-06T07:42:52.953 回答
1

第一的,

事件:'htpp://example.com/getevents.php',

这是一个错字吗 - 它应该是http

我在代码中使用的是$('#calendar').fullCalendar('renderEvent', calEvent)方法,其中 calEvent 是日历方法的 json 表示。这样,每当您在服务器端添加日历事件时,它都会立即添加到日历中,而无需再次调用服务器。

否则我会尝试检查您的服务器端设置。也许您在保存新的日历事件之​​前正在查询您的日历事件。

于 2010-06-04T20:41:39.807 回答