0

I am trying to send the event id from the front end JS code to my back end server.

I am getting this error:

fullcalendar.min.js:6 Uncaught TypeError: Cannot read properties of undefined (reading 'fn')

I am using the function below, which is taking me to my html page but it is not getting the event id although the event id is correctly stored.


eventClick: function(info){
  var eventID = info.event.id;
  console.log('CLicked event ID:',eventID);
  window.location.href='/emr?eventId=' + eventID;
},
calendar.render();
  $('#appointment-form').submit(function(e){
      e.preventDefault();
      var formData =$(this).serialize();
      $.ajax({
          type:'POST',
          url:'/book_appointment',
          data: formData,
          dataType:'json',
          success: function(response){
              var eventData={
                  title :'Booked Appointment',
                  start : response.start_time,
                  end: response.end_time,
                  backgroundColor: 'green',
                  borderColor: 'green',
                  textColor: 'white',
                  eventId:response.eventId,


                  extendedProps:{
                  patientName: response.patient_name,
                      family:response.patient_family_name,
                      doctorName: response.treating_physician,
                  }
              };
              calendar.addEvent(eventData);
              $('#appointmentModal').modal('hide');
<link href='https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css' rel='stylesheet'>
<link href='https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css' rel='stylesheet'>
    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/fullcalendar@6.1.8/index.global.min.js"></script>


<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.1/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
ADyson
  • 57,178
  • 14
  • 51
  • 63
  • So it's the `var eventID = info.event.id` line which throws that error, is that correct? It wasn't fully clear from your description. If so, what makes you think the `id` should exist? I notice that in your other piece of code, when you are running `calendar.addEvent(eventData);`, the `eventData` object you pass in does not have an `id` defined. (You've defined `eventId`, but this is not the same thing, it's a different name, so fullcalendar will treat that as an extended property, it won't parse it into the `id` field - see also https://fullcalendar.io/docs/event-parsing) – ADyson Aug 23 '23 at 10:06

0 Answers0