jQuery fullcalendar:如何保存拖动和重新调整大小的项目

时间:2012-02-01 01:05:12

标签: php mysql ajax fullcalendar

从昨天开始,我正在寻找一种方法来保存(mysql + php)拖动并使用jQuery fullcalendar重新调整项目大小。没有教程,只有几个例子。有人可以发布他的工作json.php,json-events.php和外部数据库更新脚本吗?或者引导我阅读最佳解释,教程或示例?

I'm trying to get this fully working

所有人都非常感谢!

3 个答案:

答案 0 :(得分:5)

它可能无法完全回答您的问题,但希望这会指向正确的方向。基本上我正在尝试做同样的事情,但在ASP .NET中,使用日历作为数据操纵器,并以某种方式从日历中捕获更新的事件并发送回服务器进行更新。

我注意到有一些事件回调可能很有用。

  1. eventDrop回调 - 在日历上删除/移动事件时触发 http://arshaw.com/fullcalendar/docs/event_ui/eventDrop/

  2. eventResize回调 - 在调整事件大小时触发 http://arshaw.com/fullcalendar/docs/event_ui/eventResize/

  3. 我想您可以使用所涉及的事件详细信息对服务器进行ajax调用,以便相应地更新事件。

答案 1 :(得分:2)

根据FullCalendar V4文档-https://fullcalendar.io/docs/eventResize

如果要使用可接受的格式保存和检索开始日期和结束日期,请使用.toISOString()

var calendar = new Calendar(calendarEl, {
 events: [
   // events here
 ],
 editable: true,
 eventResize: function(info) {
   alert(info.event.title + " end is now " + info.event.end.toISOString());
   if (!confirm("is this okay?")) {
     info.revert();
   }
 }
});

答案 2 :(得分:0)

完整日历v4 在文档的帮助下

日历选项内

eventDrop: function(info) {
  if(!confirm("Are you sure about this change?")) {
  info.revert();
}
  modifyEvent(info.event);

使用Ajax更新

<script>
function modifyEvent(event) {

  var start = event.start;
  var end = event.end;
  $.ajax({
    type:"POST",
    url:"/appointment/update",
    data:{"id":event.id,"start":start,"end":end},
    traditional:true,
    success:function(msg){
      console.log(msg);
    },
    error:function(msg){
      console.log(msg);
      alert('We are unable to process your request');
    }
  });
}
</script>