将外部事件拖到fullcalendar上,并使用json将其保存到数据库中



此示例:http://arshaw.com/js/fullcalendar-1.6.3/demos/external-dragging.html

但是如何使用json将外部div数据保存到我的数据库中呢。

您可以listen拖动&在fullcalendar中删除事件并执行任何操作。类似这样的东西:

var events = []; //array of events in json format
var calendar = $('#calendar-container').fullCalendar({
theme: true,
header: {
    left: 'prev,next today',
    center: 'title',
    right: 'month,agendaWeek,agendaDay'
},
selectable: true,
selectHelper: true,
select: function(start, end, allDay) {
    console.log('create new event');
},
editable: true,
droppable: true,
events: events,
eventDrop: function(event, delta) {
    console.log('move exists event');
    saveEvent(event);
},
loading: function(bool) {},
eventClick: function(calEvent, jsEvent, view) {
    console.log('edit exists event');
}
});
function saveEvent(event){
   $.ajax({
       url: 'save_event.php',
       type: 'post',
       data: {event: event},
       dataType: 'json',
       success: function(response){
          console.log('response');
       }
  });
}

移动时,将调用事件fullCalendar.eventDrop()。您可以在插件文档中查看所有事件函数

相关内容

  • 没有找到相关文章