javascript - FullCalendar:如何在 eventDrop (node.js) 上保存/发送修改后的事件到数据库或服务
问题描述
我有一个 FullCalendar 对象集成到我的 node.js 解决方案中,它通过来自面向数据库的 REST 服务的 json 接受事件。
一旦将更新的事件拖到新的时间段(在 eventDrop 上),如何将更新的事件保存回中央数据库?
global.js
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
defaultView: "timeGridWeek",
height: "auto",
slotDuration: "00:60:00",
navLinks: true,
events: '/classes/jsonlist',
plugins: [ 'dayGrid', 'timeGrid', 'interaction' ],
editable: true,
eventDrop: function(info) {
var new_event_start_time = info.event.start.toLocaleTimeString();
if (!confirm("Are you sure you want to move it to "+new_event_start_time+" ?")) {
info.revert();
};
// Update database record for the event
//
var xhr = $.ajax({
url: "/classes/jsonset",
type: "POST",
contentType: "application/json",
data: JSON.stringify( { 'id': info.event.id, 'url': info.event.url, 'title': info.event.title,'new_start': info.event.start } ),
timeout: 5000
}).done(function( msg ){
alert( "Data Saved: " + msg );
});
}
}
);
calendar.render();
});
解决方案
推荐阅读
- customization - 如何在到期日自动延长 maximo 合同?
- javascript - 如何在 html (pug) 文件中使用 axios?
- javascript - ReactJS:使用按钮执行 POST 和 GET 请求
- flutter - 菜单绘制不断返回两个应用栏。怎么只退一个?
- maven - Cucumber Cluecumber 报告 - POM:在 POM 文件中传递命令行,而不是在终端中输入
- python - 寻找最近邻=,TypeError:只有整数标量数组可以转换为标量索引
- javascript - 如何根据浏览器窗口的宽度动态设置表格宽度
- neo4j - 为什么这个 neo4j 密码查询无法重写?
- zsh - mv 命令创建了一个可执行文件而不是一个目录
- ruby - 如何让机架在退出时执行代码(sigterm)?从机架开始