2010-12-02 110 views
2

我使用ColdFusion從http://arshaw.com/fullcalendar/實施FullCalendar。我將外部事件從日曆中刪除。這是工作很好,但我不能更新FullCalendar:拖放一個事件,但無法更新此事件

$('#calendar').fullCalendar('updateEvent', responseText.NewID); 

我需要這樣做,我可以把新的ID從DEM數據庫上的事件,像調整大小等操作時,拖放到其他日或刪除它。

我可以從整個網站做一個重新加載,但它不是真正用戶友好的,因爲這個月將是實際的月份,而不是我之前選擇的月份。

我的代碼看起來是這樣的:

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); 

    var formdata = "startdatum="+copiedEventObject.start; 

    $.ajax({ 
    url: '<cfoutput>#application.TartalomURL#</cfoutput>mod_Kalender/act_event_ins.cfm', 
    data: formdata, 
    type: "POST", 
    dataType: "json", 
    cache: false, 
    success: function(responseText){ 
    $('#calendar').fullCalendar('updateEvent', responseText.NewID); 
    } 
     }); 
}, 

有沒有人有一個想法是什麼,我的編程錯誤?

+0

您是否收到可以在此處發佈的錯誤? – 2010-12-02 21:58:23

+0

如果您使用控制檯,請添加console.log(responseText)並查看返回的內容 – 2010-12-02 21:59:02

+2

我的猜測是,NewID可能是大寫字母。 – 2010-12-02 21:59:20

回答

2

由於JavaScript是大小寫敏感的,應該這行:

$('#calendar').fullCalendar('updateEvent', responseText.NewID) 

$('#calendar').fullCalendar('updateEvent', responseText.newid) 
3

請參閱fullcalendar文檔: arshaw fullcalendar updateEvent

您需要的情況下使用updateEvent方法即:

$.ajax({ 
    url: '<cfoutput>#application.TartalomURL#</cfoutput>mod_Kalender/act_event_ins.cfm', 
    data: formdata, 
    type: "POST", 
    dataType: "json", 
    cache: false, 
    success: function(responseText){ 
     originalEvent.id = responseText.newid; //use the originating event object and update it 
     $('#calendar').fullCalendar('updateEvent', originalEvent); 
    } 
    });