2014-11-01 66 views
0

我希望把我的JSON數據(我成功地獲得)進入FullCalendar插件事件,但偏偏它不工作對我來說...jQuery的FullCalendar活動

$('#calendar').fullCalendar({ 
     events: function (start, end, timezone, callback) { 
      $.getJSON("http://localhost:3000/test/2014-09-09", function (data, stat) { 
       alert(data[0].dates[0].dateStart) 
start:data[0].dates[0].dateStart 
      }); 
     } 
    }); 
+0

請做一個jsFiddle來說明你的問題。由於localhost是您的機器,您需要對返回的json字符串進行硬編碼。 – 2014-11-01 02:15:01

+0

用您提取的事件調用回調 – 2014-11-01 10:04:24

回答

0

我有同樣的事情在我以前的項目是這樣的。我還以JSON格式獲取數據。

我環路我的JSON數據,並在fullCalendar如下

首先要功能

function Event(_id, _title, _start, _color, _editable, _inspectorID, _complaintID, _productID, _seasonYearID, _inspectionType) { 
var newEvent = new Object(); 

newEvent.id = _id; 
newEvent.title = _title; 
newEvent.start = _start; 
newEvent.color = _color; 
newEvent.editable = _editable; 
newEvent.allDay = true; 
newEvent.durationEditable = false; 
/* Custom Properties*/ 
newEvent.InspectorID = _inspectorID; 
return newEvent; 
} 

這個對象,然後添加到壓延如下

$('#calendar').fullCalendar('renderEvent', Event(newID, productName, _events.Date, "#" + _events.EventColor, editable, _events.InspectorID)); 

希望這將幫助你。