1
我有一个接受外部事件的日历,当您单击日历创建事件时,使用eventDrop
我阻止(revertFunc()
)添加一个事件,如果日期在过去,现在我想在revertFunc()
时添加或删除的事件与已经在该特定日期的事件匹配。起初,我试图比较event.Title
,但我找不到参数eventDrop
中的任何函数或属性,它们已经存在。我还将overlap
设置为false,但这不起作用,因为我想在所有情况下允许重叠,除非重复。FullCalendar:Event.Title相同时的块重叠
请参阅Fiddle for example.在这拨弄你可以一遍又一遍地产品A添加到同一日期,如果你取消注释eventOverlap: false
代码,那么你不能将产品A或产品B到已包含产品的日期。相反,如果日期已经包含您要删除/添加的产品,我需要它不允许投放/添加。我希望我有道理。
<select id="productDd">
<option selected="selected">Select Product...</option>
<option value="a">A</option>
<option value="b">B</option>
<option value="c">C</option>
</select>
<div id="calendar">
</div>
var todaysDate = moment();
$('#calendar').fullCalendar({
theme: true,
header: {
left: '',
center: 'title',
right: ''
},
selectable: true,
eventDurationEditable: false,
select: function(start, end, jsEvent) {
if (end < todaysDate) {
//block addition of dates to old calendars
Alert("Sorry product order dates can not be added to days in the past.")
return false;
}
var title, code, eventData;
if ($('#productDd option:selected').text() == "Select Product...") {
$('body').scrollTop(0);
Alert("Please select a product from the drop down in order to add products to the calendar.");
} else {
title = $('#productDd option:selected').text();
code = $('#productDd option:selected').val();
}
if (title) {
eventData = {
title: title,
start: start,
end: end,
className: title,
productCode: code
};
$('#calendar').fullCalendar('renderEvent', eventData, true);
}
$('#calendar').fullCalendar('unselect');
},
//eventOverlap: false,
eventDrop: function(eventData, delta, revertFunc) {
if (moment(eventData._start).format('YYYY-MM-DD') < todaysDate.format('YYYY-MM-DD')) {
//block modification of old dates
revertFunc();
}
},
eventClick: function (calEvent, jsEvent, view) {
$('#calendar').fullCalendar('removeEvents', calEvent._id);
},
editable: true,
businessHours: {
start: '7:00',
end: '18:00',
dow: [1, 2, 3, 4, 5]
},
eventLimit: true
});
谢谢你看着我。