2011-02-17 121 views
2

我希望能夠更改任何新創建事件的默認持續時間。FullCalendar - 默認事件持續時間

我在dayView中,如果我只是在日曆上點擊(不拖動&下拉列表),我會得到一個半小時的會話。

我想將其設置爲默認一小時。

, select: function (startDate, endDate, allDay, jsEvent, view) { 
    endDate = new Date(startDate); 
    endDate.setHours(endDate.getHours() + 1); 
} 

這有效地設置好結束日期,但不visualy更新

half hour selection screenshot


編輯

我:

用這種代碼

也許米試以使行爲類似於Google日曆:如果用戶點擊它,則會選擇1小時事件,但用戶仍可以選擇半小時。

回答

2

基礎上的一個例子:

select: function(start, end, allDay) { 
    var title = prompt('Event Title:'); 
    if (title) { 
     end = new Date(start); 
     end.setHours(end.getHours() + 1); 

     calendar.fullCalendar('renderEvent', 
     { 
     title: title, 
     start: start, 
     end: end, 
     allDay: allDay 
     }, 
     true // make the event "stick" 
     ); 
    } 
    calendar.fullCalendar('unselect'); 
}, 

問題的更新之前:

像這樣的東西應該工作:

eventClick: function (calEvent, jsEvent, view) { 
    calEvent.end = new Date(calEvent.start); 
    calEvent.end.setHours(calEvent.start.getHours() + 1); 
    $('#calendar').fullCalendar('updateEvent', calEvent); 
}, 
+0

我在說「eventClick」時犯了一個錯誤。事實上,我正在談論新會議的定義,而不是現有會議的定義。所以更多的是關於「選擇」事件。 (我已更新我的問題) – 2011-02-17 15:18:10

0

這是臨時的解決方案,我發現:

在您的fullcalendar.js文件,找到名爲slotSelectionMousedown的函數。更改dates = ...線(S)本:

if (cell == origCell && (t.name == "agendaWeek" || t.name == "agendaDay")) 
     dates = [ 
      d1, 
      addMinutes(cloneDate(d1), snapMinutes), // calculate minutes depending on selection slot minutes 
      d2, 
      addMinutes(cloneDate(d2), snapMinutes + 30) 
     ].sort(cmp); 
    else 
     dates = [ 
      d1, 
      addMinutes(cloneDate(d1), snapMinutes), // calculate minutes depending on selection slot minutes 
      d2, 
      addMinutes(cloneDate(d2), snapMinutes) 
     ].sort(cmp); 

請注意,這只是治標不治本/黑客,因爲它會用新版本Fullcalendar覆蓋。您可能會嘗試再次添加這些行,但有可能無法使用。