- trop de trucs d'un coup... je vais faire attention ensuite ^^'
This commit is contained in:
21
assets/controllers/bootstrap-modal_controller.js
vendored
Normal file
21
assets/controllers/bootstrap-modal_controller.js
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Controller } from '@hotwired/stimulus';
|
||||
import { Modal } from 'bootstrap';
|
||||
|
||||
/**
|
||||
* Allows you to dispatch a "modal:close" JavaScript event to close it.
|
||||
*
|
||||
* This is useful inside a LiveComponent, where you can emit a browser event
|
||||
* to open or close the modal.
|
||||
*
|
||||
* See templates/components/BootstrapModal.html.twig to see how this is
|
||||
* attached to Bootstrap modal.
|
||||
*/
|
||||
/* stimulusFetch: 'lazy' */
|
||||
export default class extends Controller {
|
||||
modal = null;
|
||||
|
||||
connect() {
|
||||
this.modal = Modal.getOrCreateInstance(this.element);
|
||||
document.addEventListener('modal:close', () => this.modal.hide());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user