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.
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:
- Import the package and the styles -
import { Booking } from "@dhx/trial-booking"and itsbooking.css. - Add the container to the template as
<div ref="container" class="widget"></div>with a height in your CSS. - Create the widget in
mounted()-this.booking = new Booking(this.$refs.container, { data: this.data }). - Declare the prop with
props: ["data"]and pass the cards from the parent as<Booking :data="dataset" />. - Answer the confirmation -
this.booking.setConfirmHandler(event => ...)runs when a visitor confirms a slot. The demo waits a second and picksconfirm.done()orconfirm.error()at random, so both results of the booking dialog are visible. - Destroy it in
unmounted()withthis.booking.destructor().
API reference
- Integration with Vue: Component, props, and required styles
- data: The card and slot format the prop carries
- setConfirmHandler(): Handling a confirmed slot and reporting the result
- Properties overview: Every configuration property
Related examples
- React integration: the widget inside a React component
- Angular integration: the widget inside an Angular component
- Initialization: the base setup with cards, slots, and a confirm handler