antoniandre / vue-cal

A Vue.js full calendar, no dependency, no BS. :metal:
https://antoniandre.github.io/vue-cal/
MIT License
1.24k stars 238 forks source link

Error thrown when creating event with :on-event-create and :dragToCreateEvent="false" #577

Closed Dandjix closed 3 months ago

Dandjix commented 3 months ago
    <vue-cal
      :events="events"

      class="week-planning-calendar vuecal--full-height-delete"

      :editable-events="{ title: false, drag: true, resize: true, delete: true, create: true }" 
      :dragToCreateEvent="false"

      :on-event-create="onEventCreated"
      />

      with method
          methods: {
  onEventCreated(event)
  {
    console.log("created an event : "+JSON.stringify(event));

    this.events.push(event)
  }
}

      produces the error message : 
      Cannot destructure property '_eid' of 'this.utils.event.createAnEvent(...)' as it is undefined.

TypeError: Cannot destructure property '_eid' of 'this.utils.event.createAnEvent(...)' as it is undefined. at eval (webpack-internal:///./node_modules/vue-cal/dist/vue-cal.es.js:947:21)

when you try and create an event... The event is still created and the error is thrown outside my function, so i cannnot catch it.
Dandjix commented 3 months ago

i hadn't understood how things worked.

onEventCreated(event) { console.log("created an event : "+JSON.stringify(event));

this.events.push(event)

return event

}

is how things should be done