Ticket Form
Advanced
Using onReady and onError events

Ticket Form - Using the onReady and onError event callbacks

How it works

When the DOM elements are registered on the page, the ticket elements will make an initial request to the Aidbase API to fetch the configuration for the element.

When the configuration is fetched and validated, the ticket elements will be ready to use.
The onReady() callback will be called immediately after the ticket element is ready.

If the ticket elements encounters an error during the process described above, the onError() callback will be called.

HTML
<ab-create-ticket
  id='my-ticket-form'
  ticketFormID='YOUR-TICKET-FORM-ID'
  // ...additional attributes
></ab-create-ticket>

Example

JavaScript
// Get the DOM node of the Ticket Form
const ticketform = document.getElementById('my-ticket-form');
 
// Set the onReady callback
ticketform.onReady = () => {
  console.log('Ticket Form is ready!');
};
 
// Set the onError callback
ticketform.onError = (error) => {
  console.error('Something went wrong: ' + error);
};

Aidbase Docs © 2024