外部イベントをカレンダーにドラッグアンドドロップする機能があります。開始時刻のデフォルトの動作は、イベントがドロップされた場所です。デフォルトの動作を設定して、イベントの終了時刻も開始時刻の1時間後に設定したいと思います。これは些細なことのようですが、私はそれを機能させることができないようです。以下は私のドロップ機能です(基本的にドロップ可能なアイテムのデモに1行を加えたものです)。
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();
}
},
何か案は?
ありがとう、ジョー・チン