【发布时间】:2019-10-01 08:55:24
【问题描述】:
在 div 中使用静态事件可以正常工作。但是当我用动态事件填充 div 时,我收到以下错误:
fullcalendar.bundle.js:1036 Uncaught TypeError: Cannot read property 'startTime' of undefined
at refineProps (fullcalendar.bundle.js:1036)
at Object.parseDragMeta (fullcalendar.bundle.js:8140)
at ExternalElementDragging.buildDragMeta (fullcalendar.bundle.js:12401)
at EmitterMixin.ExternalElementDragging.handleDragStart (fullcalendar.bundle.js:12315)
at applyAll (fullcalendar.bundle.js:981)
at EmitterMixin.triggerWith (fullcalendar.bundle.js:3523)
at EmitterMixin.trigger (fullcalendar.bundle.js:3518)
at EmitterMixin.HitDragging.handleDragStart (fullcalendar.bundle.js:11484)
at applyAll (fullcalendar.bundle.js:981)
at EmitterMixin.triggerWith (fullcalendar.bundle.js:3523)
我正在使用 fullcalendar v4,以启用事件拖动:
var Draggable = FullCalendarInteraction.Draggable;
new Draggable(containerEl, {
itemSelector: '.fc-draggable-handle',
eventData: function(eventEl) {
return $(eventEl).data('event');
}
});
有人可以帮忙吗?
编辑:
错误似乎来自这里,但我明白为什么。当我更改此代码时:
$('#kt_calendar_external_events .fc-draggable-handle').each(function() {
// store data so the calendar knows to render an event upon drop
$(this).data('event', {
id: $(this).attr("data-id"),
startEditable: true,
durationEditable: true,
title: $.trim($(this).text()), // use the element's text as the event title
stick: true, // maintain when user navigates (see docs on the renderEvent method)
classNames: [$(this).data('color')],
description: 'Lorem ipsum dolor eius mod tempor labore',
source: 'planificacion'
});
});
这是可行的,但我需要稍后才能再次拖动事件并调整大小...
$('#kt_calendar_external_events .fc-draggable-handle').each(function() { // 存储数据,以便日历知道在放置时呈现事件
$(this).data('event', {
title: $.trim($(this).text()), // use the element's text as the event title
stick: true, // maintain when user navigates (see docs on the renderEvent method)
classNames: [$(this).data('color')],
description: 'Lorem ipsum dolor eius mod tempor labore'
});
});
【问题讨论】:
-
这是固定的,有兴趣的可以告诉我。 Fullcalendar 版本 4,PHP Mysql
标签: jquery fullcalendar draggable fullcalendar-4