gpt4 book ai didi

javascript - 通过拖放 fullcalendar-Javascript 来更新事件

转载 作者:数据小太阳 更新时间:2023-10-29 04:30:06 27 4
gpt4 key购买 nike

我正在使用 Fullcalendar对于我正在开发的项目...我只剩下一个功能要实现,即当现有事件从其原始位置拖到另一个时间或日期时。我想知道如何获取当前对象信息(标题、新开始时间、旧开始时间、id、url 等),以便我可以使用较新的信息更新数据库……Fullcalendar 对象的哪个属性执行我用?我实现了 drop 属性;

    drop  : function(date, allDay) {
// 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 object
var copiedEventObject = $.extend({}, originalEventObject);
// assign it the date that was reported
copiedEventObject.start = date;
copiedEventObject.allDay = allDay;

// render the event on the calendar
// the last `true` argument determines if the event `sticks`
$('#calendar').fullCalendar('renderEvent', copiedEventObject, true);

// if the 'remove after drop' checkbox checked?
if ($('#drop-remove').is(':checked')) {
// if so remove the element from the "Draggable Events"
$(this).remove();
}
},

但它并没有按照我的意愿行事......

最佳答案

查看事件拖动和调整大小 http://arshaw.com/fullcalendar/docs/event_ui/

我认为您正在寻找 eventDrop 回调。

Triggered when dragging stops and the event has moved to a different day/time.

http://arshaw.com/fullcalendar/docs/event_ui/eventDrop/

arshaw 网站的示例:

$('#calendar').fullCalendar({
events: [
// events here
],
editable: true,
eventDrop: function(event,dayDelta,minuteDelta,allDay,revertFunc) {

alert(
event.title + " was moved " +
dayDelta + " days and " +
minuteDelta + " minutes."
);

if (allDay) {
alert("Event is now all-day");
}else{
alert("Event has a time-of-day");
}

if (!confirm("Are you sure about this change?")) {
revertFunc();
}

}
});

关于javascript - 通过拖放 fullcalendar-Javascript 来更新事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19434303/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com