0
我想將保存在數據庫中的事件呈現給日曆模板。 所有事件作爲對象過去了,可像這樣進行檢索:將事件從數據庫上傳到FullCalendar
{% for object in objects %}
var start = "{{ object.start }}";
var end = "{{ object.end }}";
var name = "{{ object.name }}";
{% endfor %}
我可以證實,這是工作,因爲我看到它在Sources
標籤,當我檢查的頁面。所以我有一些事件存儲在數據庫中,我想渲染這些事件。
所以看 documentation,我想過做這樣的事情:
$('#calendar').fullCalendar({
eventSources: [
// your event source
{
events: [ // put the array in the `events` property
{% for object in objects %}
var start = "{{ object.start }}"; // Can't seem to identify this statement
var end = "{{ object.end }}";
var name = "{{ object.name }}";
var event={id:1 , title: name, start: start, end:end};
//$('#calendar').fullCalendar('renderEvent', event, true);
{
title : name,
start : start,
end : end,
}
{% endfor %}
]
}
// any other event sources...
]
});
但events
陣列返回空在Sources
檢查選項卡中顯示。我一直堅持這一點。有任何想法嗎?
編輯:
如果我做這樣的事:如果我點擊日期
select: function(start,end){
{% for object in objects %}
var name = "{{ object.name }}";
var start = "{{ object.start }}";
var end = "{{ object.end }}";
var event={id:1 , title: name, start: start, end:end};
$('#calendar').fullCalendar('renderEvent', event, true);
{% endfor %}
事件將顯示。所以我認爲如果我包裝在function
它會起作用。這就是說,有像在fullcalendar initialize()
函數?