mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 04:46:21 +00:00
feat: poder ocultar con un evento también
This commit is contained in:
parent
71a15ae693
commit
8cafe32ce7
1 changed files with 6 additions and 0 deletions
|
@ -6,13 +6,16 @@ export default class extends Controller {
|
|||
// TODO: Stimulus >1
|
||||
connect() {
|
||||
this.showEvent = this.show.bind(this);
|
||||
this.hideEvent = this.hide.bind(this);
|
||||
|
||||
window.addEventListener("modal:show", this.showEvent);
|
||||
window.addEventListener("modal:hide", this.hideEvent);
|
||||
}
|
||||
|
||||
// TODO: Stimulus >1
|
||||
disconnect() {
|
||||
window.removeEventListener("modal:show", this.showEvent);
|
||||
window.removeEventListener("modal:hide", this.hideEvent);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -41,6 +44,9 @@ export default class extends Controller {
|
|||
|
||||
hide(event = undefined) {
|
||||
event?.preventDefault();
|
||||
const modalId = event?.detail?.id;
|
||||
|
||||
if (modalId && this.element.id !== modalId) return;
|
||||
|
||||
this.backdropTarget.classList.remove("show");
|
||||
this.modalTarget.classList.remove("show");
|
||||
|
|
Loading…
Reference in a new issue