Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
Why Bootstrap modal deletes my click events

I use a Bootstrap modal to create a popup and when it closes, all the click events of my documents are deleted, included the one I have just clicked. Could you help me, please?

To activate the modal, I click on a button with the id "btnAddPortfolio".

function initBtnPortfolioMainContentAddPortfolio(){
    let btnAddPortfolio = document.getElementById("btnAddPortfolio");
    btnAddPortfolio.addEventListener("click", () => {
        displayPopUpLoadFileCreatePortfolio();
     });
}

function displayPopUpLoadFileCreatePortfolio(){
    let root = document.getElementById("root");
    let html = [];
    
    if (document.getElementById("PopUpLoadFileCreatePortfolio") === null){
        html.push('<div id="PopUpLoadFileCreatePortfolio" class="modal" tabindex="-1">',
                    '<div class="modal-dialog modal-dialog-centered">',
                      '<div class="modal-content">', 
                        '<div class="modal-header bg-info">', 
                          '<h5 class="modal-title">Créer un nouveau portefeuille</h5>', 
                          '<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>', 
                        '</div>', 
                        '<div class="modal-body">', 
                          '<div class="mb-3">', 
                            '<label for="formFile" class="form-label">Sélectionner le fichier à importer:</label>', 
                            '<input class="form-control" type="file" id="formFile">', 
                          '</div>', 
                        '</div>', 
                        '<div class="modal-footer">', 
                          '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Annuler</button>', 
                          '<button type="button" class="btn btn-primary">Valider</button>', 
                        '</div>', 
                      '</div>', 
                    '</div>', 
                  '</div>', 
        );
        strHTML = html.join('\n');
        root.innerHTML += strHTML;
    }
    let PopUp = new bootstrap.Modal(document.getElementById('PopUpLoadFileCreatePortfolio'), {
      keyboard: false
    });
    PopUp.show();
}

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!