Display an API generated popup list using Vue's rendering capabilities

I'm attempting to generate a pop-up within a displayed list using custom content retrieved from an API request.

Currently, my code looks like this:

<template>
  <div class="biblio__all">
      <a v-for="i in items" v-bind:key="i.id" class="biblio__item">
          <div class="biblio__text">
            <h3 class="biblio__title">{{ i.gsx$titre.$t }}</h3>
            <p class="biblio__author">{{ i.gsx$auteur.$t }}</p>
          </div>
      </a>

  </div>

</template>

<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
    data() {
        return{
            items: [],
        }
    },
    created(){
            this.axios.get("///API URL")
            .then(response => (this.items = response.data.feed.entry))
        },
    methods: {
        
    }
        
    })
    
</script>

What I am aiming for in the v-for loop is to include another hidden div and show it as a popup when clicking on the link.

All the necessary data for the pop-up is already stored in the items array.

Answer №1

If you want to create a separate component for each item and manage its modal state within that component, you have several options such as using Bootstrap, Bulma, or simply Pure HTML/CSS for building the modal. Utilize v-show="modalState" to toggle the visibility of the modal. Make sure to define the modalState in your subcomponent:

data() {
    return {
        modalState: false
    }
}

Your final structure should look like this:

<div class="biblio__all">
      <a v-for="i in items" v-bind:key="i.id" class="biblio__item">
          <!-- This is where you include the component with modal code and main item -->
          <subitem :item="i" />
      </a>

  </div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Troublesome update: Migrating XState's Reddit example from Vue 2 to Vue 3

Recently, I delved into the XState documentation and decided to explore the Reddit sample provided in the official guide. You can find it here: As I attempted to upgrade the sample implementation to Vue 3 following the work of Chris Hannaby, I encountered ...

What is the correct way to declare a DocumentReference type within an Angular TypeScript interface?

Thank you for taking the time to read my inquiry. Technologies used: Angular 13, Firebase Firestore v9 database, and Firebase Authentication. My question pertains to the process of signing up a user through Firestore Authentication. Upon signup, I need ...

Exploring Cypress: Leveraging the Power of Variable Assignment

Recently, I encountered an issue while working with a variable in a Cypress each loop. Despite incrementing the variable within the loop, it resets to zero once outside of it. Can someone shed light on why this happens and suggest a solution? Thank you. p ...

Integrating Multiple Select Boxes in VUEjs Templates

Struggling to build a rapport with Vue at work, I find myself facing an issue that I'm not sure how to resolve. Let me try to explain the problem to the best of my abilities with the limited Vue knowledge that I possess. Basically, I have a Vue compo ...

Sending a request in Vue.js and not receiving a defined response

As a beginner in VueJs and Expressjs, my goal is to create the frontend using Vuejs and backend using ExpressJs. When I send a post request to the backend (ExpressJs), I encounter the following issues: 1- Response from the server is undefined. 2- In Chrom ...

implement a discount and waive tax computation specifically for Canadian customers

I have encountered a problem while developing a POS application for a client in Canada. My issue lies in the tax calculation process, where I am unsure how to handle discounts and tax exemptions properly. Here is the scenario: I have 2 items - item 1 price ...

Encountering npm error code 1 during npm installation in a Vue.js project

Recently, I installed VueJS Material Dashboard (with Laravel), but encountered an issue with the npm install command on this VueJS template. The error message displayed was related to gyp and python39. Even when running the node.js command prompt as admini ...

Content obscuring dropdown menu

I am currently working on a screen design that resembles the following: return ( <SafeAreaView> <View style={styles.container}> <View style={styles.topContainer}> <View style={styles.searchFieldContainer}> ...

Upgrade Angular from 12 to the latest version 13

I recently attempted to upgrade my Angular project from version 12 to 13 Following the recommendations provided in this link, which outlines the official Angular update process, I made sure to make all the necessary changes. List of dependencies for my p ...

What causes the v-for in a template to only update when the input text changes?

I'm currently working on a Vue.js code, but I'm facing an issue where the template isn't updating when new data is added to the input text. My goal is for the list to update when the @click event occurs. Visit this link for reference metho ...

The request for the option was unsuccessful due to a 404 error

I'm facing an issue with sending a GET request from my frontend to an API application, both running on my local machine. The setup looks like this: backend <===> frontend <=x=> API application Each component runs in its own docker contai ...

Leverage a JavaScript plugin from the node modules directory within your Vue.js project

Is there a way to import Cal-HeatMap (https://www.npmjs.com/package/cal-heatmap) into my project after saving it with npm install? This is the method I attempted: <script> import calHeatmap from 'cal-heatmap' export default { na ...

Displaying default value in select dropdown using v-model

I am working on a Vue selectbox with an initial v-model value, and I want to display its value on the selectbox. However, I am unsure of how to accomplish this. Any assistance would be greatly appreciated. new Vue({ el: "#demo", data() { return ...

Having trouble directing my attention towards a Mat card when using viewchildren in Angular

My current challenge is trying to focus on a specific card from a list of mat cards Despite my efforts, I keep encountering an error that reads: Cannot read property 'focus' of undefined Access the code on StackBlitz The desired functionali ...

What is the most effective method for ensuring a Vue application can accurately interpret the environmental variables configured on Heroku?

I implemented a Vue app that is currently being hosted on Heroku. Since Heroku doesn't support static apps, I decided to create a basic express server to serve my app. //server.js const express = require('express') const serveStatic = requi ...

Is there a way to execute Typescript tests using JasmineKarma within a TFS Build Process?

My current setup involves a web application using Angular 1.5 with bower/npm/gulp written in Typescript for our build process. The back end is a c# .net WebApi2, and both are built and deployed on TFS2015. Integrating my c# NUnit tests into the build proce ...

JavaScript method of retrieving an object inside an array nested within another object via multer

Below is my custom multer function to handle file uploads - const storage = multer.diskStorage({ destination: (req, file, callback) => { let type = req.params.type; let path = `./data/${type}`; fs.mkdirsSync(path); callback(null, path) ...

Exploring the functionality of dynamic component imports in jest testing

Under a specific condition, I dynamically imported a component and stored it in an object property. Then, I displayed it in the template using vue <component :is="">. Everything is functioning correctly at the component level. However, I am ...

When invoking a JavaScript method, the context variable 'this' is lost

I have developed a basic pointer to a method like this: export class SmbwaService { getExistingArsByLab(labId: number): Observable<SmwbaAr[]> { this.otherMethod(); } otherMethod(): void { } } let method: (x: number) => ...

Leverage the child interface as a property interface containing a generic interface

I'm facing an issue while trying to incorporate typings in React. The concept is centered around having an enum (EBreakpoint) that correlates with each device we support. A proxy wrapper component accepts each device as a prop, and then processes the ...