我使用Fullcalendar从http://arshaw.com/fullcalendar/,我有搜索stackoverflow,但没有答案适合我的问题,或者我不明白。如果这已经是答案,请粘贴链接。
我有一个返回事件的xml文件:
事件例子:<event allDay="false" editable="true" end="Mon Apr 29 2013 15:30:00 GMT+0100" id="53" start="Mon Apr 29 2013 08:30:00 GMT+0100" title="tesete"/>
如果你注意到起始日和结束日,时间格式是这样保存的。
当我像这样获取事件时:
events: function(start, end, callback) {
$.ajax({
type: 'POST',
url: url,
dataType:'xml',
crossDomain: true,
data: {
// our hypothetical feed requires UNIX timestamps
start: Math.round(start.getTime() / 1000),
end: Math.round(end.getTime() / 1000),
'ajax':true,
'acc':'2',
},
success: function(doc) {
var events = [];
$(doc).find('event').each(function()
{
events.push({
id: $(this).attr('id'),
title: $(this).attr('title'),
start: $(this).attr('start'),
end: $(this).attr('end'),
allDay: $(this).attr('allDay'),
editable: $(this).attr('editable')
});
});
callback(events);
}
});
},
所有事件显示在月视图正确,但当我切换到议程视图或日视图,事件只在全天栏,他们不呈现在特定的小时之间。
start="Mon Apr 29 2013 08:30:00 GMT+0100" end="Mon Apr 29 2013 15:30:00 GMT+0100" id="53"
从8:30到15:30例如
我错过了什么?
解决问题的方法:
events: function(start, end, callback) {
$.ajax({
type: 'POST',
url: 'myurl',
dataType:'xml',
crossDomain: true,
data: {
// our hypothetical feed requires UNIX timestamps
start: Math.round(start.getTime() / 1000),
end: Math.round(end.getTime() / 1000),
'ajax':true,
'acc':'2',
},
success: function(doc) {
var events = [];
var allday = null; //Workaround
$(doc).find('event').each(function()
{
if($(this).attr('allDay') == "false") //Workaround
allday = false; //Workaround
if($(this).attr('allDay') == "true") //Workaround
allday = true; //Workaround
events.push({
id: $(this).attr('id'),
title: $(this).attr('title'),
start: $(this).attr('start'),
end: $(this).attr('end'),
allDay: allday,
editable: $(this).attr('editable')
});
});
callback(events);
}
});
},
Var allDay不能是字符串。应该是不带引号的allDay=false