How To Get Start And End Date Of External Dragged And Dropped Event On Fullcalendar
I have a quick question about fullcalendars drag and drop functionality. Here is my JS Code $('#calendar').fullCalendar({ header: { left: 'prev,next today', ri
Solution 1:
You can try something like
drop: function (date, allDay) {
console.clear();
console.log("dropped");
console.log(date.format());
var defaultDuration = moment.duration($('#calendar').fullCalendar('option', 'defaultTimedEventDuration'));
var end = date.clone().add(defaultDuration); // on drop we only have date given to usconsole.log('end is ' + end.format());
// retrieve the dropped element's stored Event Objectvar originalEventObject = $(this).data('eventObject');
// we need to copy it, so that multiple events don't have a reference to the same objectvar copiedEventObject = $.extend({}, originalEventObject);
// assign it the date that was reported
copiedEventObject.start = date;
copiedEventObject.allDay = allDay;
copiedEventObject.backgroundColor = $(this).css("background-color");
copiedEventObject.borderColor = $(this).css("border-color");
// 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();
}
}
Gives this result
OR follow this example.
Solution 2:
There is on overload for
drop: function(date, allDay)
wich is
drop: function(start, end, allDay)
The start and end dates are stored into the 'start' and 'end' variables.
Post a Comment for "How To Get Start And End Date Of External Dragged And Dropped Event On Fullcalendar"