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

161
Views
how to display the right movie informations in an overlay?

I'm looking for solutions to display the right movie information in my overlay. I have a "popup window" that appears when i click on a movie and it is supposed to display movie's informations in it but when I click on a movie, no matter which one it is, it only displays the last movie informations, what Should I do to fix it ?

const movieIntegration =() => {
    allMovies.map(movie=> {
        movieGallery.innerHTML += `<div class="imgContainer">
                                        <img src="${movie.img}" alt="${movie.name}">
                                                <div class="titleContainer">
                                                    <div class="movieTitle"> ${movie.name} </div>
                                                    <div class="seemore"> See more </div>
                                                </div>
                                    </div>`

        const seemore = document.querySelectorAll(".seemore")
        seemore.forEach(elm => {
            elm.addEventListener("click",() => {
                pageContainer.innerHTML += `<div class="popupContainer">
                                                <div class="popup">

                                                    ${movie.name}

                                                    <div id="likeButton">
                                                        <img src="img/like.png">
                                                    </div>

                                                    <div id="editButton">
                                                        <img src="img/edit.png">
                                                    </div>

                                                    <a href="submit.html">
                                                        <div id="addingButton">
                                                            <img src="img/add.png">
                                                        </div>
                                                    </a>
                                                </div>
                                            </div>`
                console.log(true)
            }, true)
        })
    })
    
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

the problem is that you are getting all the .seemore element for each movie and you are editing the content of ALL elements for each movie, so the last movie will overwrite the content for all the previous.

A solution could be something like this:

const movieIntegration = () => {
  allMovies.map((movie) => {
    movieGallery.innerHTML += `<div class="imgContainer">
                                <img src="${movie.img}" alt="${movie.name}">
                                <div class="titleContainer">
                                  <div class="movieTitle"> ${movie.name} </div>
                                  <div class="seemore"> See more </div>
                                </div>
                              </div>`
  })
  const seemore = document.querySelectorAll('.seemore')
  seemore.forEach((elm, i) => {
    elm.addEventListener(
      'click',
      () => {
        pageContainer.innerHTML += `<div class="popupContainer">
                                      <div class="popup">
                                        ${allMovies[i].name}
                                        <div id="likeButton">
                                          <img src="img/like.png">
                                        </div>
                                        <div id="editButton">
                                          <img src="img/edit.png">
                                        </div>
                                        <a href="submit.html">
                                          <div id="addingButton">
                                            <img src="img/add.png">
                                          </div>
                                        </a>
                                      </div>
                                    </div>`
      },
      true
    )
  })
}

In this way you are mapping the .seemore elements AFTER you finish the map of allMovies and, for each .seemore element you get the associated movie and write his name inside.

about 4 years ago · Juan Pablo Isaza Report
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!