CroudTech/vue-fullcalendar

Disable Date

Closed this issue · 5 comments

I'm trying to disable the dates before the current date but I can not get it.

I do not understand how I get the days before the current date

I appreciate the help you can give me

this my code

dayRender: function (date, cell) {     
          var today = new Date(); 
         if (date < today.getDate()) {
              cell.css("background-color", "green");
          }
}

Is your question about the specific if statement? Or how you would disable days before today?

how you would disable days before today?
the code that I have does not work

I don't think there is an off the shelf solution for this. You could probably build something with a combination of the dayRender and dayClick callbacks. dayRender for the styling of the disabled dates and the dayClick callback to only call an event creation callback if the date is not disabled?

if that may be an option, but I wanted to disable the previous dates, so that the end user understood that he can not assign any event in those days, and thus avoid trying to click on each day.

thanks for the appreciation

on the web I found this solution, which applies to my situation.

dayClick: function( date, jsEvent, view) {
          if (moment().format('YYYY-MM-DD') === date.format('YYYY-MM-DD') || date.isAfter(moment())){
                 // This allows today and future date
          }else {
              // Else part is for past dates              
          }
   }