我正在使用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