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

前端之家收集整理的这篇文章主要介绍了通过拖放fullcalendar- Javascript来更新事件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用 Fullcalendar进行我正在开发的项目…我只剩下一个要实现的功能,即将现有事件从其原始位置拖动到另一个时间或日期.我想知道如何获取当前对象信息(标题,新开始时间,旧开始时间,ID,URL等),因此我可以使用更新的信息更新数据库… Fullcalendar对象中的哪个属性我用?
我实现了drop属性;
  1. drop : function(date,allDay) {
  2. // retrieve the dropped element's stored event object
  3. var originalEventObject = $(this).data('eventObject');
  4. // we need to copy it,so that multiple events don't
  5. // have a reference object
  6. var copiedEventObject = $.extend({},originalEventObject);
  7. // assign it the date that was reported
  8. copiedEventObject.start = date;
  9. copiedEventObject.allDay = allDay;
  10.  
  11. // render the event on the calendar
  12. // the last `true` argument determines if the event `sticks`
  13. $('#calendar').fullCalendar('renderEvent',copiedEventObject,true);
  14.  
  15. // if the 'remove after drop' checkBox checked?
  16. if ($('#drop-remove').is(':checked')) {
  17. // if so remove the element from the "Draggable Events"
  18. $(this).remove();
  19. }
  20. },

但它没有做我想要的……

解决方法

看一下事件拖动和调整大小 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网站的示例:

  1. $('#calendar').fullCalendar({
  2. events: [
  3. // events here
  4. ],editable: true,eventDrop: function(event,dayDelta,minuteDelta,allDay,revertFunc) {
  5.  
  6. alert(
  7. event.title + " was moved " +
  8. dayDelta + " days and " +
  9. minuteDelta + " minutes."
  10. );
  11.  
  12. if (allDay) {
  13. alert("Event is now all-day");
  14. }else{
  15. alert("Event has a time-of-day");
  16. }
  17.  
  18. if (!confirm("Are you sure about this change?")) {
  19. revertFunc();
  20. }
  21.  
  22. }
  23. });

猜你在找的JavaScript相关文章