Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

192
Vistas
Vue make each v-for have own version of variable

i am looping through an array displaying songs I have uploaded into firebase. I am giving the user a button to edit the name of the song if they press the edit button. When button is pressed it show to edit details, however, except of only the one object expanding all of them expand to edit. How can I give each object its own version of the showForm Bool thanks.

Displaying songs:

<div v-for="song in watchSongs" :key="song.docID">
            <div class="mt-[10px] border-solid border-2 border-gray-400 rounded-lg p-[5px] min-h-[40px]">
                <p class="font-bold float-left">{{song.modifiedName}}</p>
                <img @click.prevent="showForm = !showForm" src="@/assets/edit.png" alt="" class="w-[20px] float-right hover:cursor-pointer">
                <img src="@/assets/close2.png" alt="" class="w-[20px] float-right hover:cursor-pointer">
            <div v-if="this.showForm" class="pt-[30px]">
                <p>song title</p>
                <input type="text" placeholder="Enter Song Title" class="w-[100%] h-[30px] pl-[5px] mt-[10px] bg-transparent border-[1px] border-solid border-gray-300">
                <p>Genre</p>
                <input type="text" placeholder="Enter genre" class="w-[100%] h-[30px] pl-[5px] mt-[10px] bg-transparent border-[1px] border-solid border-gray-300">
                <div class="flex mt-[20px] mb-[10px]">
                    <button class="bg-green-500 rounded-md w-[70px] mr-[5px]">Submit</button>
                    <button class="bg-gray-400 rounded-md w-[70px]">Go back</button>
                </div>
            </div>
        </div>

The data:

export default {
name:"AppUploadDetails",
props: ['songs'],
data(){
    return{
        showForm:false,
    }
},
computed:{
    watchSongs(){
        return this.songs;
    }
}

}

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Fixed by changed the v-if to v-if="song.showForm" and the click to @click.prevent="song.showForm"

about 4 years ago · Juan Pablo Isaza Denunciar

0

Use an object to store your loop items, with the key being the docID.

Something like this:

showForm: {}
click.prevent="showForm[song.docID] = !showForm[song.docID]
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda