Javascript fullcalendar事件移除不使用eventDragStop方法(full calendar v4)

Javascript fullcalendar事件移除不使用eventDragStop方法(full calendar v4),javascript,fullcalendar,draggable,fullcalendar-4,Javascript,Fullcalendar,Draggable,Fullcalendar 4,我正在使用fullcalendar v4。我想删除eventDragStop方法中的事件 一切都很好,但我无法删除事件。实际上,我想要在fullcalendar中删除外部事件,也想要在外部事件区域中删除fullcalendar事件 。我想用最新版本(v4)构建类似的演示 例子: eventDragStop:函数(信息){ if(isEventOverDiv(info.jsEvent.clientX,info.jsEvent.clientY)){ info.event.remove(); var

我正在使用fullcalendar v4。我想删除eventDragStop方法中的事件

一切都很好,但我无法删除事件。实际上,我想要在fullcalendar中删除外部事件,也想要在外部事件区域中删除fullcalendar事件

。我想用最新版本(v4)构建类似的演示

例子:
eventDragStop:函数(信息){
if(isEventOverDiv(info.jsEvent.clientX,info.jsEvent.clientY)){
info.event.remove();
var el=$(“”).appendTo(“#外部事件列表”).text(info.event.title);
可拖动的({
zIndex:999,
回复:对,
恢复持续时间:0
});
el.data('event',{title:info.event.title,id:info.event.id,stick:true});
}
},
完整代码:

document.addEventListener('DOMContentLoaded',function(){
var Calendar=FullCalendar.Calendar;
var Draggable=FullCalendarInteraction.Draggable;
var containerell=document.getElementById('external-events');
var calendarEl=document.getElementById('calendar');
var checkbox=document.getElementById('drop-remove');
新拖船(集装箱船{
itemSelector:“.fc事件”,
eventData:函数(eventEl){
返回{
标题:eventEl.innerText
};
}
});
var calendar=新日历(calendarEl{
插件:['interaction','dayGrid','timeGrid'],
标题:{
左:“上一个,下一个今天”,
中心:'标题',
右图:“dayGridMonth、timeGridWeek、timeGridDay”
},
是的,
droppable:true,//这允许将内容拖放到日历上
删除:功能(信息){
//是否选中了“删除后删除”复选框?
如果(复选框。选中){
//如果是,请从“可拖动事件”列表中删除该元素
info.draggedEl.parentNode.removeChild(info.draggedEl);
}
},
eventDragStop:函数(信息){
if(isEventOverDiv(info.jsEvent.clientX,info.jsEvent.clientY)){
info.event.remove();
var el=$(“”).appendTo(“#外部事件列表”).text(info.event.title);
可拖动的({
zIndex:999,
回复:对,
恢复持续时间:0
});
el.data('event',{title:info.event.title,id:info.event.id,stick:true});
}
},
});
calendar.render();
var isEventOverDiv=函数(x,y){
变量外部事件=$(“#外部事件”);
var offset=外部事件。offset();
offset.right=外部事件.width()+offset.left;
offset.bottom=外部事件.height()+offset.top;
//比较
如果(x>=offset.left
&&y>=offset.top

&&x“不能”不是错误消息或问题声明。您的代码到底出了什么问题?我使用v4制作了一个小演示。我看不到明显的问题,它似乎按设计工作。您能否更具体地说明在dragstop事件中看到的错误或意外行为?谢谢。请查看此旧版本演示。我想添加ex新版本中的ternal dragable事件(请参见左侧事件)。请仔细查看此演示。我希望您理解。谢谢-@adysoni在问题中您说“要在eventDragStop方法中删除事件。”您现在是否提出了不同的要求?请尝试将您的问题集中在一个问题上,并澄清您需要帮助的问题。还不清楚您在实施要求时具体遇到了什么问题。请解释具体问题(而不仅仅是“我想”).你试了什么?出了什么问题?有什么你不明白的吗?“不能”不是错误消息或问题声明。您的代码到底出了什么问题?我使用v4制作了一个小演示。我看不到明显的问题,它似乎按设计工作。您能否更具体地说明在dragstop事件中看到的错误或意外行为?谢谢。请查看此旧版本演示。我想添加ex新版本中的ternal dragable事件(请参见左侧事件)。请仔细查看此演示。我希望您理解。谢谢-@adysoni在问题中您说“要在eventDragStop方法中删除事件。”您现在是否提出了不同的要求?请尝试将您的问题集中在一个问题上,并澄清您需要帮助的问题。还不清楚您在实施要求时具体遇到了什么问题。请解释具体问题(而不仅仅是“我想”).你试了什么?出了什么问题?有什么你不明白的吗?
    eventDragStop: function( info ) {
        if(isEventOverDiv(info.jsEvent.clientX, info.jsEvent.clientY)) {
            info.event.remove();
            var el = $( "<div class='fc-event'>" ).appendTo( '#external-events-listing' ).text( info.event.title );
            el.draggable({
              zIndex: 999,
              revert: true, 
              revertDuration: 0 
            });
            el.data('event', { title: info.event.title, id: info.event.id, stick: true });
        }
    },
 <pre>

    document.addEventListener('DOMContentLoaded', function() {
      var Calendar = FullCalendar.Calendar;
      var Draggable = FullCalendarInteraction.Draggable;

      var containerEl = document.getElementById('external-events');
      var calendarEl = document.getElementById('calendar');
      var checkbox = document.getElementById('drop-remove');

      new Draggable(containerEl, {
        itemSelector: '.fc-event',
        eventData: function(eventEl) {
          return {
            title: eventEl.innerText
          };
        }
      });
      var calendar = new Calendar(calendarEl, {
        plugins: [ 'interaction', 'dayGrid', 'timeGrid' ],
        header: {
          left: 'prev,next today',
          center: 'title',
          right: 'dayGridMonth,timeGridWeek,timeGridDay'
        },
        editable: true,
        droppable: true, // this allows things to be dropped onto the calendar
        drop: function(info) {
          // is the "remove after drop" checkbox checked?
          if (checkbox.checked) {
            // if so, remove the element from the "Draggable Events" list
            info.draggedEl.parentNode.removeChild(info.draggedEl);
          }
        },
        eventDragStop: function( info ) {
            if(isEventOverDiv(info.jsEvent.clientX, info.jsEvent.clientY)) {
                info.event.remove();
                var el = $( "<div class='fc-event'>" ).appendTo( '#external-events-listing' ).text( info.event.title );
                el.draggable({
                  zIndex: 999,
                  revert: true, 
                  revertDuration: 0 
                });
                el.data('event', { title: info.event.title, id: info.event.id, stick: true });
            }
        },
      });
      calendar.render();

        var isEventOverDiv = function(x, y) {
            var external_events = $( '#external-events' );
            var offset = external_events.offset();
            offset.right = external_events.width() + offset.left;
            offset.bottom = external_events.height() + offset.top;

            // Compare
            if (x >= offset.left
                && y >= offset.top
                && x <= offset.right
                && y <= offset .bottom) { return true; }
            return false;
        }


    });

</pre>