我的json包含两个事件。
在即11日,事件在同一天呈现, 一个是在26/5/2014,另一个是在27/5/2007
var myevents =[{"id":99,"title":"","start":"2014-05-26T07:30:00Z","end":"2014-05-26T13:00:00Z","color":"#fff","textColor":"#000","borderColor":"#000","allDay":false},{"id":101,"title":"","start":"2014-05-27T13:00:00Z","end":"2014-05-27T17:00:00Z","color":"#fff","textColor":"#000","borderColor":"#000","allDay":false}]
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
year: 2014,
month: 4,
events: function (start, end, callback) {
//console.log(myevents);
var obj = myevents//jQuery.parseJSON(myevents);
var events = new Array();
$.each(obj, function (index, value) {
console.log(value)
event = new Object();
event.id = value['id']
event.title = value['start'];//value['id'];
event.start = value['start'];
event.end = value['end'];
event.color = value['color'];
event.textColor = value['textColor'];
event.borderColor = value['borderColor'];
event.allDay = false;
console.log(event);
events.push(event);
});
callback(events);
}
});
答案 0 :(得分:0)
问题出在array.push上 我将每个循环更改为
$.each(obj, function (index, value) {
events.push({
id: value['id'],
start: value['start'],
end: value['end'],
title: "",
color: value['color'],
textColor: value['textColor'],
borderColor: value['borderColor'],
allDay: false,
canSubscribe: value['canSubscribe']
});
});
并且工作正常