我正在使用Rails和FullCalendar計劃程序,並且希望能夠在添加新資源時更新我作爲資源提供的JSON對象。FullCalendar計劃程序更新資源JSON對象
這裏是我的日曆選項的簡化版本:
fullcalendar-settings.js
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'promptResource, prev, next, today',
center: 'title',
right: 'agendaWeek, timelineDay'
},
customButtons: {
promptResource: {
text: '+ maker',
click: function() {
var name = prompt('Name');
if (name) {
$('#calendar').fullCalendar(
'addResource', { title: name }, true // scroll to the new source?
);
}
}
}
},
defaultView: 'timelineDay',
defaultDate: moment(),
editable: true,
resourceColumns: [
{
labelText: 'Client',
field: 'title'
}
],
resources: 'scheduler.json',
events: []
});
});
scheduler.json
[
{ "id": "1", "title": "LE" },
{ "id": "2", "title": "DB" },
{ "id": "3", "title": "VB" },
{ "id": "7", "title": "RL" }
]
資源從「調度裝.json',我有一個按鈕,您可以添加一個新的資源,但它是佛現在只是暫時的,並在重新加載時消失。
所以我的問題是當我添加新資源時,如何更新'scheduler.json'中的JSON對象?
在此先感謝
在日曆中創建事件後,您必須發送ajax請求以更新您的db,這會在下次重新加載頁面時生成scheduler.json文件。 –
我對JSON好,但不知道如何做這種請求。 – LRP