src/render.js
function(form, e, eventData) {

    e.preventDefault();

    var formElement = $(form);

    if(formElement.hasClass('success')) {
      getAvailability();
      hideBookingPage();
      return;
    }

    // Abort if form is submitting, have submitted or does not validate
    if(formElement.hasClass('loading') || formElement.hasClass('error') || !e.target.checkValidity()) {
      var submitButton = formElement.find('.bookingjs-form-button');
      submitButton.addClass('button-shake');
      setTimeout(function() {
        submitButton.removeClass('button-shake');
      }, 500);
      return;
    }

    var formData = {};
    $.each(formElement.serializeArray(), function(i, field) {
      formData[field.name] = field.value;
    });

    formElement.addClass('loading');

    utils.doCallback('submitBookingForm', formData);

    // Call create event endpoint
    timekitCreateBooking(formData, eventData).then(function(response){

      formElement.find('.booked-email').html(formData.email);
      formElement.removeClass('loading').addClass('success');

    }).catch(function(response){

      showBookingFailed(formElement)

    });

  }
function(form, e, eventData) {

    e.preventDefault();

    var formElement = $(form);

    if(formElement.hasClass('success')) {
      getAvailability();
      hideBookingPage();
      return;
    }

    // Abort if form is submitting, have submitted or does not validate
    if(formElement.hasClass('loading') || formElement.hasClass('error') || !e.target.checkValidity()) {
      var submitButton = formElement.find('.bookingjs-form-button');
      submitButton.addClass('button-shake');
      setTimeout(function() {
        submitButton.removeClass('button-shake');
      }, 500);
      return;
    }

    var formData = {};
    $.each(formElement.serializeArray(), function(i, field) {
      formData[field.name] = field.value;
    });

    formElement.addClass('loading');

    utils.doCallback('submitBookingForm', formData);

    // Call create event endpoint
    timekitCreateBooking(formData, eventData).then(function(response){

      formElement.find('.booked-email').html(formData.email);
      formElement.removeClass('loading').addClass('success');

    }).catch(function(response){

      showBookingFailed(formElement)

    });

  }
function ( form , e , eventData ) { e . preventDefault ( ) ; var formElement = $ ( form ) ; if ( formElement . hasClass ( 'success' ) ) { getAvailability ( ) ; hideBookingPage ( ) ; return ; } // Abort if form is submitting, have submitted or does not validate if ( formElement . hasClass ( 'loading' ) || formElement . hasClass ( 'error' ) || ! e . target . checkValidity ( ) ) { var submitButton = formElement . find ( '.bookingjs-form-button' ) ; submitButton . addClass ( 'button-shake' ) ; setTimeout ( function ( ) { submitButton . removeClass ( 'button-shake' ) ; } , 500 ) ; return ; } var formData = { } ; $ . each ( formElement . serializeArray ( ) , function ( i , field ) { formData [ field . name ] = field . value ; } ) ; formElement . addClass ( 'loading' ) ; utils . doCallback ( 'submitBookingForm' , formData ) ; // Call create event endpoint timekitCreateBooking ( formData , eventData ) . then ( function ( response ) { formElement . find ( '.booked-email' ) . html ( formData . email ) ; formElement . removeClass ( 'loading' ) . addClass ( 'success' ) ; } ) . catch ( function ( response ) { showBookingFailed ( formElement ) } ) ; }
Event handler on form submit
Event handler on form submit