user3437115
user3437115

Reputation: 17

Create events in React Big Calendar

I'm trying to create events in react-big-calendar by dragging, putting the data in a Tootip form and send a request to server to save it. Problem after i drag the event the selection disappears: i need it to stay until I submit the event. Right now it works like this

In the docs/examples they have alert, which of corse stops exection of function and the selection remains the same:

 <BigCalendar
      selectable
      events={events}
      defaultView='week'
      scrollToTime={new Date(1970, 1, 1, 6)}
      defaultDate={new Date(2015, 3, 12)}
      onSelectEvent={event => alert(event.title)}
      onSelectSlot={(slotInfo) => alert(
        `selected slot: \n\nstart ${slotInfo.start.toLocaleString()} ` +
        `\nend: ${slotInfo.end.toLocaleString()}`
      )}
    />

if i trow and error at the end of onSelectSlot function it stays also open the selection, but then i need to close after I submit.

Upvotes: 0

Views: 3431

Answers (1)

Uziel Valdez
Uziel Valdez

Reputation: 2280

Use the onSelecting method for dragging a selection this will give you an object with start and end date of the selection { start: Date, end: Date } and make sure to not return false on this method, for more information see the documentation here

Upvotes: 2

Related Questions