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

392
Views
Bootstrap event "shown.bs.modal" fires multiple times everytime I click the toggle button

I am building a pdf view with PDF.js to render pdf inside bootstrap modal, and according to the documentation I can listen to "shown.bs.modal" event when the modal popup is displayed so I have this code:

function renderPdfMobile() {
  docs.forEach(doc => {
    doc.addEventListener("click", function (e) {
      const file = e.target.dataset.file;

      var modal = document.getElementById("fileModal");
      modal.addEventListener('shown.bs.modal', function (event) {

      

      console.log(modal)

      })

    })

  })
}

renderPdfMobile()

Code works every time I click the modal button. The problem is it fires with the increment of +1 every time.

So in console When I click once, I get "fired" when I click again I get

"fired"
"fired"

another click results in:

"fired"
"fired"
"fired"

At this point, I don't know what I am doing wrong.

EDITED

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!