装有ajax的FullCalendar不会构建日历

时间:2013-04-07 18:26:41

标签: jquery fullcalendar

我在使用ajax加载的页面中使用FullCalendar插件。 当页面加载时,我得到的是标题按钮,但是在我点击其中一个按钮(月/周/日)之前,日历本身不会显示。

这是我的代码:

$('#calendar').fullCalendar({
    header: { left: 'next,prev, today', center: 'title', right: 'month,basicWeek,basicDay'},
    isRTL: true,
    height: 540,
    events: {
        url: "../practice/AjaxJson",
        cache: true
    },
    timeFormat: 'H(:mm)'
});     

如果我把这段代码放在一个函数中,并使用设置为1500ms的setTimeout调用它,那就可以了。

对此有更好的解决方案吗?

1 个答案:

答案 0 :(得分:0)

  1. 在dom准备就绪后尝试放置代码。
  2. 使用renderEvents(http://arshaw.com/fullcalendar/docs/event_rendering/rerenderEvents/
  3. 确保您没有在隐藏元素上加载日历。