Disable fall in past dates in FullCalendar

I recently started using the FullCalendar plugin. I am trying to implement a function when throwing events on a calendar. But before saving to the database, I want to check and disable / prevent the removal of external events by date until today.

Any idea on how to do this? I am looking for something like the days gone by when you will be gray or something like that, so that I can display the events already present. I just want the user to not delete the event on a past date.

EDIT:

drop: function (date, jsEvent, ui) { if(date<currentDate) { $('#calendar').fullCalendar('removeEvents', event.id); } 

I tried using this method to remove the event that fell out of the calendar and add it to the div again. Even then he does not leave.

Thanks.:)

+5
source share
2 answers

eventConstraint can disable drag and drop beyond set boundaries

Gray in recent days

 /* SHADE DAYS IN THE PAST */ td.fc-day.fc-past { background-color: #EEEEEE; } 

And for eventConstraint

  /* This constrains it to today or later */ eventConstraint: { start: moment().format('YYYY-MM-DD'), end: '2100-01-01' // hard coded goodness unfortunately } 

http://jsfiddle.net/1qsrjffL/

For the "end" eventConstraint, you can add days to the current date if you like vs hard-code

EDIT:

To put out the time in day mode, you can use businessHours

 businessHours: { start: moment().format('HH:mm'), /* Current Hour/Minute 24H format */ end: '17:00', // 5pm? set to whatever dow: [0,1,2,3,4,5,6] // Day of week. If you don't set it, Sat/Sun are gray too } 

Drop external events on the agenda. In past allowed. Editing eventConstraint to include time will work "YYYY-MM-DD HH: mm", but it prevents a fall today in the "Month" view ...

http://jsfiddle.net/1qsrjffL/1/

+8
source

eventDrop should get there:

 eventDrop: function(event, delta, revertFunc) { if(event.start < currentDate) { revertFunc(); } } 
+3
source

Source: https://habr.com/ru/post/1235110/


All Articles