2011-11-22 40 views
0

我正在嘗試使用fullcalendar來拖動事件。我想要的是當我將事件拖放到事件添加到數據庫的日曆中時。我也想要的是,當我從日曆中拖動現有的事件到數據庫中的另一個日期更新fullcalendar拖動事件更新並插入到數據庫中

用json獲取現有事件是沒有問題的。

也許有人可以幫助我一個例子或一些信息進一步。

這是我的代碼如下所示:

$(document).ready(function() { 


    /* initialize the external events 
    -----------------------------------------------------------------*/ 

    $('#external-events div.external-event').each(function() { 

     // create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/) 
     // it doesn't need to have a start or end 
     var eventObject = { 
      title: $.trim($(this).text()) // use the element's text as the event title 
     }; 

     // store the Event Object in the DOM element so we can get to it later 
     $(this).data('eventObject', eventObject); 

     // make the event draggable using jQuery UI 
     $(this).draggable({ 
      zIndex: 999, 
      revert: true,  // will cause the event to go back to its 
      revertDuration: 0 // original position after the drag 
     }); 

    }); 


    /* initialize the calendar 
    -----------------------------------------------------------------*/ 

    $('#calendar').fullCalendar({ 
     header: { 
      left: 'prev,next today', 
      center: 'title', 
      right: 'month,agendaWeek,agendaDay' 
     }, 
     editable: true, 
     events: "json-events.php", 
     droppable: true, // this allows things to be dropped onto the calendar !!! 
     drop: function(date, allDay) { // this function is called when something is dropped 

      // retrieve the dropped element's stored Event Object 
      var originalEventObject = $(this).data('eventObject'); 

      // we need to copy it, so that multiple events don't have a reference to the same object 
      var copiedEventObject = $.extend({}, originalEventObject); 

      // assign it the date that was reported 
      copiedEventObject.start = date; 
      copiedEventObject.allDay = allDay; 

      // render the event on the calendar 
      // the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/) 
      $('#calendar').fullCalendar('renderEvent', copiedEventObject, true); 

      // is the "remove after drop" checkbox checked? 
      if ($('#drop-remove').is(':checked')) { 
       // if so, remove the element from the "Draggable Events" list 
       $(this).remove(); 
      } 

     } 
    }); 


}); 
+0

這只是Arshaw簡單示例的一部分的複製粘貼。根本沒有幫助。 – Laci

回答

1

你能對你有什麼下降的回調中發生了澄清?

活動是否在日曆中正確顯示?

通過調用適當的服務器方法,在JavaScript內調用ajax方法來更新數據庫。

相關問題