Jquery 完整日历多个后台事件未呈现
我在fullcalendar中使用背景事件作为假日。我是这样从数据库中获取事件的Jquery 完整日历多个后台事件未呈现,jquery,laravel,fullcalendar,Jquery,Laravel,Fullcalendar,我在fullcalendar中使用背景事件作为假日。我是这样从数据库中获取事件的 events: [ @foreach($events as $in) { id: '{{$in["id"]}}', title: '{{$in["name"]}}', start: '{{$in["interventionTime"] or ''}}',
events: [
@foreach($events as $in)
{
id: '{{$in["id"]}}',
title: '{{$in["name"]}}',
start: '{{$in["interventionTime"] or ''}}',
end: '{{$in["interventionTime"]}}',
room: '{{$in["room"]}}',
repeat: '{{$in["repeat"]}}',
limit: '{{$in["limit"]}}',
detail: '{{$in["detail"]}}',
@if($in['holiday'] == 1)
rendering: 'background',
backgroundColor: '#fb0b0b',
@endif
},
@endforeach
dayClick: function(date, jsEvent, view) {
if (jsEvent.target.classList.contains('fc-bgevent')) {
alert('You cannot create intervention on a holiday');
return false;
}
}
一切都很好。我只看到背景颜色为“fb0b0b”的背景事件
但当我试图检测像这样的背景事件时,问题就开始了
events: [
@foreach($events as $in)
{
id: '{{$in["id"]}}',
title: '{{$in["name"]}}',
start: '{{$in["interventionTime"] or ''}}',
end: '{{$in["interventionTime"]}}',
room: '{{$in["room"]}}',
repeat: '{{$in["repeat"]}}',
limit: '{{$in["limit"]}}',
detail: '{{$in["detail"]}}',
@if($in['holiday'] == 1)
rendering: 'background',
backgroundColor: '#fb0b0b',
@endif
},
@endforeach
dayClick: function(date, jsEvent, view) {
if (jsEvent.target.classList.contains('fc-bgevent')) {
alert('You cannot create intervention on a holiday');
return false;
}
}
只有最后一个后台事件被检测到,其他事件则没有。我很困惑,背景色应用于每个背景事件,但渲染:“背景”仅应用于最后一个事件。
请提供帮助。那么您正试图阻止用户创建与您的背景事件重叠的事件 如果是这样,那么首先,不要使用dayClick创建事件-这应该通过处理select回调来完成,该回调检测用户选择并允许他们在日历上拖动鼠标以指示他们希望事件发生的特定时间段。看 完成此操作后,通过设置selectOverlap选项,您可以轻松防止用户在后台事件或任何其他事件上方添加事件: 如果您希望允许与其他事件重叠,但不允许与后台事件重叠,则可以将回调放在那里,而不是简单地设置为false: 对于用户选择重叠的每个事件,此操作都会运行一次,并在允许选择进行之前检查重叠的事件是否为背景事件 与您的方法相比,这里的优点是它允许您访问实际的事件对象,而不是它被呈现到的HTML元素,因此您可以检查它的所有属性,包括告诉您它是否是背景事件的呈现属性
有关详细信息,请参阅。如果jsEvent.target.classList.包含'fc-bgevent'{alert'holiday;}。你在哪里运行这个代码?jsEvent代表什么?不清楚。还有,你到底想达到什么目的?有可能这不是最好的方法,也许这不是最好的方法。我正设法安排几天假期。在完整的日历中没有这样做的选项。因此,我创建了一个背景事件,使之成为一个假日。该JsEvent来自于此日期单击:functiondate,JsEvent,view{if JsEvent.target.classList.包含'fc-bgevent'{警报'您不能在假日创建干预';返回false;}}不工作。我需要的是一种检测背景事件的方法。不幸的是,这段代码jsEvent.target.classList.包含'fc-bgevent'只检测到日期框的一部分。比方说,若我点击框的底部,这将检测到背景事件,但若我点击日期框的上方,它将不会检测到背景类c-BGEvent什么不起作用?错误?意外行为?您是否将可选:设置为true以允许用户选择日历的区域。你以前的做法不可靠,不推荐。如果您正确配置,此方法将起作用。我们感兴趣的是,您是使用我的建议还是其他方式来管理它的?