我有能力将外部事件拖放到日历,其中开始时间的默认行为是放置事件的位置。我想将默认行为设置为将事件的结束时间设置为开始时间之后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