jquery完整日历json事件源语法 [英] Jquery Full Calendar json event source syntax
问题描述
我试图使用完整的日历从JSON源加载事件。 json来自像feed这样的URL,mysite.com/getEvents(它返回一个json事件对象)。现在它返回一个对象
{allDay:false,end:1325577600,start:1325577600}
我试过
$('#calendar')。fullCalendar({
events:'mysite.com/getEvents'
});
但没有任何反应。我知道我的json缺少标题和ID。所以我们有两个问题。
- 什么是从json url获取事件的正确方法
- 如何为每个创建的事件生成一个id?
尝试形成JSON,以便它具有所有必填字段。例如,在我的项目中,以下内容就足够了:
- id
- title
- 开始
- 结束
- allDay
我认为该ID只对JSON提要的实例唯一,所以您可以在生成JSON的服务器端脚本中增加一个计数器。
JSON脚本的输出示例:
[
0,
{
allDay:,
title:测试事件,
id:821,
end:2011-06-06 14:00:00,
start:2011-06-06 06:00:00
},
1 ,
{
allDay:,
title:测试事件2,
id:822,
结束 :2011-06-10 21:00:00,
开始:2011-06-10 16:00:00
}
]
I'm trying to use full calendar to load events from a json source. The json is from a URL like a feed, "mysite.com/getEvents" (which returns a json event object). Right now it returns an object
{"allDay":false,"end":1325577600,"start":1325577600}
I tried
$('#calendar').fullCalendar({
events: 'mysite.com/getEvents'
});
But nothing happens. I know my json is missing the title and the id. So we have 2 questions.
- What is the proper way to get the events from a json url
- How do I go about generating an id for every event created?
You should try forming the JSON so it has all the required fields. For example, on my project the following is sufficient:
- id
- title
- start
- end
- allDay
I think the ID only has to be unique for that instance of the JSON feed, so you could just have a counter incrementing in the server-side script that generates the JSON.
Example output from the JSON script:
[
"0",
{
"allDay": "",
"title": "Test event",
"id": "821",
"end": "2011-06-06 14:00:00",
"start": "2011-06-06 06:00:00"
},
"1",
{
"allDay": "",
"title": "Test event 2",
"id": "822",
"end": "2011-06-10 21:00:00",
"start": "2011-06-10 16:00:00"
}
]
这篇关于jquery完整日历json事件源语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!