Varinder Sohal
Varinder Sohal

Reputation: 1292

How can I stop to drag the event in previous dates but I also want to show the past events?

I am working on a react project and using a FullCalendar but I need to stop drag and drop event in previous days so to achieve this I used validRange function. This function shows the date from the current date and hides the past dates and events but I also want to show past events and their dates. How can I do this?

<FullCalendar
   plugins={[dayGridPlugin, timeGridPlugin, interactionPlugin]}
   headerToolbar={{
      left: 'prev,next today',
      center: 'title',
      right: 'dayGridMonth,timeGridWeek,timeGridDay'
   }}
   initialView='dayGridMonth'
   editable={true}
   selectable={true}
   selectMirror={true}
   dayMaxEvents={true}
   weekends={this.state.weekendsVisible}
   initialEvents={this.state.list}
   select={this.dateSelectHandle}
   eventClick={(event) => console.log(event)}
/>

Upvotes: 1

Views: 260

Answers (1)

Varinder Sohal
Varinder Sohal

Reputation: 1292

I used eventDrop method to achieve what I want with the following:

eventDrop={(info) => {
   if (new Date() > info.event._instance.range.start){
      info.revert();
   }
}}

Upvotes: 1

Related Questions