我有能力將外部事件拖放到日曆,其中開始時間的默認行爲是放置事件的位置。我想將默認行爲設置爲將事件的結束時間設置爲開始時間之後1小時。這似乎微不足道,但我似乎無法得到它的工作。下面是我的拖放功能(基本上是可拖放項目演示加上1行)。FullCalendar FullCalendar:在放置功能中設置事件結束
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.end = date.setHours(date.getHours()+1); // <- should be working
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();
}
},
任何想法?
謝謝, 喬·奇
嗨萊利,感謝您的反饋,雖然allday屬性可能會導致問題,我不認爲它是我特定情況的根本原因。看起來開始設置爲(Fri Nov 11 2010 09:30:00 GMT-0800(PST))格式的日期,而結束時間設置爲紀元時間。我在將時代結束從世紀轉換爲UTC的過程中。如果您有任何提示,我會欣賞他們。 – JoeChin 2010-11-13 00:00:09
@JoeChin - 看看我上面的編輯,我這次實際測試過,似乎做的是正確的事情... – Ryley 2010-11-13 00:16:31
這是工作完美。謝謝。 – JoeChin 2010-11-13 00:32:37