2011-01-10 95 views
1

我相當確定這是一個錯誤。一旦我調用刪除「removeEvents」,沒有後續添加(「renderEvent」)的工作,而那些行爲像他們沒有「粘性」。renderEvent在呼叫removeEvents後失敗 - FullCalendar

如果我做到以下幾點:

  1. 初始化日曆。
  2. 添加事件A使用$("#calendar").fullCalendar('renderEvent', newEvent, true);
  3. 使用$("#calendar").fullCalendar('removeEvents', 12345);
  4. 刪除此事件中使用$("##calendar").fullCalendar('renderEvent', newEvent2, true);

無論是事件A或B出現添加事件B!兩個事件都有不同的ID,應該發生的事件是事件A被刪除,但事件B應該出現。如果我將此單個「removeEvent」取出,則會顯示事件A和B(即使刪除僅針對事件A的ID)。

即使我在步驟4之後使用$("#calendar").fullCalendar('rerenderEvents');重新渲染事件,仍然事件B不顯示。

更有趣的是,這似乎不是一個簡單的「渲染」問題,因爲如果我使用$("#calendar").fullCalendar('clientEvents', ...);拉動所有事件,它不會在返回的事件數組中顯示事件A或B, 「removeEvent」將允許事件A和B出現在數組中。

的解決方案似乎是做了之後刪除所有的補充道:

  1. 添加事件A
  2. 添加事件B
  3. 刪除事件A

其中DOES保持事件B,但在我的應用程序中,我具有拖放功能,用戶可以隨時「添加」新事件!所以我發現當我稱之爲「removeEvent」時,將新事件拖入日曆會使事件的「粘性」消失,因此更改一個月不會保留該添加的事件。

這裏是我的代碼:

$('#calendar').fullCalendar({ 
    theme: true, 
    header: { 
     left: "prev,next today", 
     center: 'title', 
     right: "today prev,next" 
    }, 
    height: 400, 
    selectable: true, 
    selectHelper: true, 
    unselectAuto: false, 
    select: calendarSelect, 
    droppable: true, 
    drop: calendarDrop, 
    events:getCalendarData, 
    eventClick:calendarEventClicked 
}); 

var newEvent = { 
    id: 12345, 
    period: "Full-day", 
    title: "Full-day", 
    start: new Date(2010, 11, 02), 
    type: "Regular", 
    billable: true, 
    className: "", 
    changedThisSession: true 
}; 

$("#calendar").fullCalendar('renderEvent', newEvent, true); 

$("#calendar").fullCalendar('removeEvents', 12345); 

var newEvent2 = { 
    id: 4433, 
    period: "Full-day", 
    title: "Full-day", 
    start: new Date(2010, 11, 03), 
    type: "Regular", 
    billable: true, 
    className: "", 
    changedThisSession: true 
}; 
$("#calendar").fullCalendar('renderEvent', newEvent2, true); 

即使這個代碼刪除ID爲12345,其他場次(編號4433)事件也未顯示。刪除行...「removeEvents」...導致顯示這兩個事件。

再一次,我可以添加新的事件,拖動它們等等,它很好用。只要「removeEvents」被調用一次,事情就會變得怪異。

幫助,將不勝感激!

-Brian

回答

1

我剛剛升級從1.4.9到1.4.10,清除我的緩存,並試圖再次,現在看起來一切正常。

希望就是這樣。

-Brian