While working on integrating a modal with the id myModal
, I am attempting to connect it with events that trigger when it is shown and closed. I referred to the documentation at and implemented the following in my modal component:
this.modalElement = document.getElementById("myModal");
this.modalElement.addEventListener("hidden.bs.modal", this.onModalHidden);
this.modalElement.addEventListener("shown.bs.modal", this.onModalShown);
Currently, the event handlers are set up to simply log "shown" or "hidden" for testing purposes, but I am encountering difficulty getting it to function as intended:
private onModalShown = (event) => {
console.log("modal is shown!!!");
}
I'm wondering if there might be something missing or if there's another way to achieve this?