我正在使用FullCalendar插件,并试图使其无法删除新事件,而该事件被拖入工作时间之外。我拥有它,所以你不能拖到当前日期之前的任何日期,但无法弄清楚如何阻止说周末被拖到。FullCalendar防止事件在工作时间以外丢失
我不想要一个硬编码的解决方案,因为我必须专门为周末做一个if语句,因为如果我想增加营业时间,例如星期三在某个特定的星期,并且只允许在下午1点到下午4点之间?所以我需要一个动态的解决方案,我可以像事件一样传递一些JSON:句柄和businessHours可以处理的事件。
$(document).ready(function() {
/* initialize the external events
-----------------------------------------------------------------*/
$('#external-events .fc-event').each(function() {
// store data so the calendar knows to render an event upon drop
$(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)
});
// make the event draggable using jQuery UI
$(this).draggable({
zIndex: 999,
revert: true, // will cause the event to go back to its
revertDuration: 0 // original position after the drag
});
});
/* initialize the calendar
-----------------------------------------------------------------*/
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
droppable: true, // this allows things to be dropped onto the calendar
drop: function() {
// is the "remove after drop" checkbox checked?
if ($('#drop-remove').is(':checked')) {
// if so, remove the element from the "Draggable Events" list
$(this).remove();
}
},
/* This constrains it to today or later */
eventConstraint: {
start: moment().format('YYYY-MM-DD'),
end: '2100-01-01' // hard coded must have
},
businessHours: {
start: moment().format('HH:mm'), /* Current Hour/Minute 24H format */
end: '17:00' // 5pm
}
});
});
这里是我当前的例子的小提琴http://jsfiddle.net/htexjtg6/
我已经提到过,在想要能够将新事件拖到日期的情况下,即使它具有特定的时间限制......可能会将时间拖到最早在工作时间内上市的时间。这对于FullCalendar来说是不可能的,只能将事件添加到日常视图中? – eqiz
@eqiz如果我正确地理解了你,那是在小提琴中工作。 – VisualBean
我的意思是提到能够在赏金中按月查看。我的意思是说,你所说的部分是不可能的,它只能使用每周或每天的视图来拖动事件而不是每月进行一次? – eqiz