[Vuejs]-How to Open MODAL after its been added to DOM – vue 3 bootstrap 5 nodejs

0👍

Alright, i found a solution, works pretty good.

Instead of using myModal.show() i used myModal.toggle("anime-card-modal-" + animeID) and the else statement is not needed in the event method:

async checkAnimeListForRelated(animeID) {
     
      if (!this.animeList.filter((anime) => anime.id === animeID).length > 0) {
        const res = await axios.get("/api/anime", {
          params: { id: animeID },
        });
       
        if (res.data.data.length > 0) {
          this.animeList.push(res.data.data[0]); 
          console.log("added to list");
          this.$parent.$nextTick(() => {  
            const myModal = new Modal(
              document.getElementById("anime-card-modal-" + animeID)
            );
             myModal.toggle("anime-card-modal-" + animeID) <---------------
        }
      }
      // Add the anime to the list
    },

Leave a comment