Skip to main content

DHTMLX Booking. Vue integration example

Demo of DHTMLX Booking integration with Vue using the official GitHub demo. Shows the component wrapper, props for the cards, a confirm handler, and cleanup on unmount. For a step-by-step setup, see the detailed Vue integration guide.

Try it online

View on GitHub - open the repository and click "Open in Codespaces" on the README page to launch a configured Vue app with DHTMLX Booking. No local setup required.

The Vue component keeps a <div ref="container"> in its template, and this.$refs.container is the element the widget mounts into. Everything else stays plain JavaScript, so the configuration object is the same one a page without a framework would use.

The instance is created in mounted(), once the template element exists. The cards arrive from the parent as a data prop and go straight into the configuration. In that same hook the demo calls setConfirmHandler, which answers each slot a visitor confirms. The instance is kept on the component so unmounted() can call destructor() when the view is left.

Solution overview​

To run DHTMLX Booking inside a Vue application:

  1. Import the package and the styles - import { Booking } from "@dhx/trial-booking" and its booking.css.
  2. Add the container to the template as <div ref="container" class="widget"></div> with a height in your CSS.
  3. Create the widget in mounted() - this.booking = new Booking(this.$refs.container, { data: this.data }).
  4. Declare the prop with props: ["data"] and pass the cards from the parent as <Booking :data="dataset" />.
  5. Answer the confirmation - this.booking.setConfirmHandler(event => ...) runs when a visitor confirms a slot. The demo waits a second and picks confirm.done() or confirm.error() at random, so both results of the booking dialog are visible.
  6. Destroy it in unmounted() with this.booking.destructor().

API reference​

Additional resources​