我第一次使用fullcalendar。起初它似乎很直接但后来出现问题。好的我正在尝试使用eventSource加载多个源。它加载所有谷歌日历源没有问题,但没有显示json feed。我想知道它是否因为我使用静态json文件来测试或者我遗漏了某些东西,或者json格式错误。我是否需要在java中编写json feed来测试(使用java)?这些是我看过的内容,我查看了有关fullcalendar和json的其他链接,但没有人帮忙。如果有人能给我一些帮助,那将非常感激。
feed.json
{
"events":
[
{
"id": "0",
"title": "Business Lunch",
"start": "2015-09-03T13:00:00",
"end": "2015-09-03T14:00:00",
"constraint": "businessHours"
},
{
"id": "2",
"title": "Conference",
"start": "2015-09-18",
"end": "2015-09-19",
"constraint": "businessHours"
},
{
"id": "3",
"title": "Party",
"start": "2015-09-29T20:00:00",
"end": "2015-09-29T24:00:00",
"constraint": "businessHours"
}
]
}
代码示例
eventSources: [
// your event source
//feed source
{
url: '/hairzone/feed.json',
type: 'GET', //GET or POST
dataType: 'json',
data: {
custom_param1: 'something',
custom_param2: 'somethingelse'
},
error: function() {
alert('there was an error while fetching events!');
},
color: 'yellow', // a non-ajax option
textColor: 'black' // a non-ajax option
},
// any other sources...
{
googleCalendarId: 'some calendar id',
color: 'pink', // an option!
textColor: 'black', // an option!
//rendering: 'background'
overlay:false
},
// any other sources...
{
googleCalendarId: 'some calendar id',
color: 'blue', // an option!
textColor: 'black', // an option!
rendering: 'background',
overlay:false
}
]
答案 0 :(得分:0)
我解决了这个问题。对于fullcalendar,似乎没有正确格式化Feed。它只需要从括号开始的一切。无论是静态文件还是生成的Feed都无关紧要。
[
{
"id": "0",
"title": "Business Lunch",
"start": "2015-09-03T13:00:00",
"end": "2015-09-03T14:00:00",
"constraint": "businessHours"
},
{
"id": "2",
"title": "Conference",
"start": "2015-09-18",
"end": "2015-09-19",
"constraint": "businessHours"
},
{
"id": "3",
"title": "Party",
"start": "2015-09-29T20:00:00",
"end": "2015-09-29T24:00:00",
"constraint": "businessHours"
}
]