0
我試圖從數據庫載入事件,但它只載入一個事件,我正在按照完整日曆JSON格式準備JSON字符串(在下面的代碼中爲「EventData」),並且轉換爲 JSON對象。當我將JSON字符串轉換爲JSON對象(下面的代碼中的「objEventData」)。它僅顯示來自所有事件的一個事件。事件無法在完整日曆中載入
下面是我的代碼:
var EventData = '';
var date = new Date();
for (var i = 0; i < data.length; i++)
{
var StartDate = formatdate(data[i].start.toString(), "mm-dd-yyyy").toString();
var newDate = new Date(StartDate);
var d = newDate.getDate();
var m = newDate.getMonth();
var y = newDate.getFullYear();
EventData = EventData + '{' + "title:" + "'" + data[i].title + "'," + "start:" + "'" + new Date(y, m, d) + "'," + ' allDay: false,' + "url:" + "'" + data[i].url + "'" + '},';
}
EventData = EventData.substring(0, EventData.length - 1);
var objEventData = eval('(' + EventData.toString() + ')');
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
events:
[
objEventData
]
});
我到底做錯了什麼?
你正在使用它與PHP或asp.net? –