Javascript 将事件拖到FullCalendar上时防止重叠
我有一些外部事件,只有当数据可共享='true'时,才应该将它们放到FullCalendar上。如果数据可共享='false',则只要该事件不与另一个已删除事件重叠,就可以删除该事件Javascript 将事件拖到FullCalendar上时防止重叠,javascript,jquery,fullcalendar,Javascript,Jquery,Fullcalendar,我有一些外部事件,只有当数据可共享='true'时,才应该将它们放到FullCalendar上。如果数据可共享='false',则只要该事件不与另一个已删除事件重叠,就可以删除该事件 if (this.getAttribute('data-shareable') == 'true' ) { $('#calendar').fullCalendar('renderEvent', copiedEventObject, true); }else{ alert('this is not a shareab
if (this.getAttribute('data-shareable') == 'true' ) {
$('#calendar').fullCalendar('renderEvent', copiedEventObject, true);
}else{
alert('this is not a shareable resource');
}
我创建了这个例子
注意:“事件2”是唯一一个可共享数据的=“false”,因此,如果它与另一个删除的事件重叠,则不应删除它。
if (this.getAttribute('data-shareable') == 'true' ) {
$('#calendar').fullCalendar('renderEvent', copiedEventObject, true);
}else{
alert('this is not a shareable resource');
}
添加了第13-14行以扩展对象,并保存有关数据id和数据共享的信息
var eventObject = {
title: $.trim($(this).text()), // use the element's text as the event title
shareable: $(this).data('shareable'),
id: $(this).data('id')
};
现在,您需要更改您的决策逻辑。
您必须检查目标事件和拖动事件是否都可共享,以及一个事件的开始或结束是否介于另一个事件和拖动事件之间
如果它们是可共享的,则无需做更多的事情;如果它们不是,则检查日期
如果日期不重叠,请继续!如果没有,请关闭并记录用户:)