0

这个例子:http ://arshaw.com/js/fullcalendar-1.6.3/demos/external-dragging.html

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

4

1 回答 1

3

您可以listen在全日历中拖放事件并执行任何操作。像这样的东西:

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()将被调用。您可以在插件文档中查看所有事件函数

于 2013-08-19T07:46:36.330 回答