Files
ephub/assets/controllers/modal_controller.js
T

15 lines
471 B
JavaScript

import { Controller } from '@hotwired/stimulus';
/*
* Closes an htmx-loaded modal by removing it from the DOM.
*
* Wired to the backdrop, the X button and a `modal-close` window event, so a fragment swapped
* into the modal can dismiss it with `htmx.trigger(window, 'modal-close')` or an HX-Trigger
* header. Opening is htmx's job; closing never needs a round trip.
*/
export default class extends Controller {
close() {
this.element.remove();
}
}