2010-08-16 38 views

回答

3

當初始化FullCalendar實例,綁定eventClick處理程序:

var calendar = $('#calendar'); 
var curr_event = null; 
calendar.fullCalendar({ 
    ... 

    events: [], 
    eventClick: function(event, jsEvent, view) { 
     curr_event = event; 
     show_form_or_something(); 
    }, 

    ... 
}); 

你可能想顯示爲了一個形式或一些允許用戶修改事件屬性(標題,開始等)。然後更新的活動早在FullCalendar實例:

$.extend(curr_event, { 
    title: 'New Event Title', 
    start: new Date() 
}); 
calendar.fullCalendar('updateEvent', curr_event); 

,並解決jmeho問題:當您添加或者通過renderEvent()或事件源FullCalendar事件

,您可以指定id爲每個事件。後添加的情況下,可以通過使用檢索事件散列/對象:

var event_obj = calendar.fullCalendar('clientEvents', 'specific event id'); 

然後可以修改具有/對象,並使用updateEvent()方法來更新顯示FullCalendar。

1

此代碼非常適合更新事件後更新日曆。
首先刪除日期事件,然後再次渲染。

function updateCalenderUP(id, title, Sessiontitle, SessionStart, Sessionend, color) {  
    title = title; 
    var id1 = id; 

    $('#calendar').fullCalendar('removeEvents', id1); 
    $('#calendar').fullCalendar('refresh'); 
    title = title; 

    if (title) { 
     calendar.fullCalendar('renderEvent', { 
       id: Eventid, 
       title: title, 
       start:startDate, 
       end: EndDate,         
       allDay: false, 
       backgroundColor:color 
      }, true // make the event "stick" 
     ); 
    } 
    calendar.fullCalendar('unselect'); 
} 
相關問題