Reputation: 385
i am having two dates in full calendar , In that '28-04-2015' and '6-05-2015'. the events which i am having , those events should drop in between the particular dates. In other dates the event should not drop in full calendar.
Upvotes: 1
Views: 1891
Reputation: 2017
You can use eventConstraint
Limits event dragging and resizing to certain windows of time.
$('#calendar').fullCalendar({
eventConstraint: {
start: '2015-06-15',//change dates according to your needs
end: '2015-06-29'
},
events: [
{
title: 'All Day Event',
start: '2015-06-01'
},
{
title: 'Long Event',
start: '2015-06-07',
end: '2015-06-10'
}
],
});
The above function will allow you to drop events between 2015-06-15
to 2015-06-29
you can change the dates according to your needs.
Alternatively you can store restricted dates in event data custom variable, and then check while event is dropped.
$('#calendar').fullCalendar({
events: [
{
title: 'All Day Event',
start: '2015-06-01',
end: '2015-06-01',
restrictedDates: ['2015-06-13', '2015-06-14', '2015-06-15']
},
{
title: 'Long Event',
start: '2015-06-07',
end: '2015-06-07',
restrictedDates: ['2015-06-15', '2015-06-16', '2015-06-17']
}
],
eventDrop: function( event, delta, revertFunc, jsEvent, ui, view ) {
if(!jQuery.inArray(event.start.format('YYYY-MM-DD'), event.restrictedDates)) {
alert('Restricted Area.');
revertFunc();
} else {
alert('Free Access');
}
}
});
The second solution is a bit more flexible as you can restrict dates for individual events, but at the end of the day the choice is yours.
Upvotes: 4