When a component is rendering a list, the data of nested components does not get updated

The parent component successfully displays the list as intended.

<stock-card
            class="col-sm"
            v-for="(stock, index) in formattedStocks"
            :stock="stock"
            :key="index"
          >
</stock-card>

However, when it comes to the child component within a modal, only the first item from the loop is rendered.

<p class="card-text text-success">{{ stock["name"] }}$</p>
<button
  class="btn btn-danger rounded-pill"
  data-bs-toggle="modal"
  data-bs-target="#exampleModal"
  @click="buyStock(stock)"
>
  Activate Modal
</button>
<modal :modalTitle="stock['name']" />

Both components have props defined.

Answer №1

The issue lies in the usage of the modal.

Typically, a bootstrap modal is triggered by using the data-bs-toggle="modal" and

data-bs-target="modalInfo"
attributes. The data-bs-target should be linked to an element with the corresponding id="modalInfo" in order to properly open and close the modal.

In this scenario, all three instances have the same data-bs-target and id values, causing them to display the same initial modal content each time.

For a functional example, please refer to this Codesandbox link.

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

Mobile phone web development using HTML5

I am currently facing an issue with playing sound on mobile browsers. In my code snippet, I have the following: Response.Write("<embed height='0' width='0' src='Ses.wav' />"); While this works perfectly fine on desktop ...

Toggle the visibility of a div by clicking on another div in a

I have created a unique design where a div features a background image of a face, along with a paragraph, two buttons, and an input box inside it. While I know this question has been asked before, my scenario is slightly different. I want the div with the ...

What could be causing the show() method to malfunction in jQuery?

My attempt at creating a basic slideshow using jQuery involves only 3 images in rotation. To navigate between images, I have utilized the next() method in my code. Here is how it is meant to function: Upon clicking a link (class="next"), a funct ...

Error encountered: Element cannot be clicked on at specified coordinates - Angular/Protractor

Recently, I have been testing out CRUD functionality in an Angular app using Protractor. One recurring issue I've encountered is with the create/edit buttons, which all open the same modal regardless of the page you're on. The frustrating part i ...

What is the method for automatically starting another .mp4 video once the first one finishes playing?

I am currently trying to replicate the functionality of a television for a project. The idea is to play a .mp4 file, and once it ends, automatically select and play another .mp4 file. It's like mimicking the TV experience where one episode finishes a ...

JS script for clicking various icons on a webpage that trigger the opening of new tabs

I am working on a webpage where I have 9 icons with the same class. I am trying to write JavaScript code that will automatically open all 9 icons when the webpage loads. I tried using the code below, but it only clicks on the first icon and stops. let ...

EventSource using HTTP Authorization Header for Secure Server Sent Events

Trying to add an Authorization header to an HTML5 EventSource, but struggling due to lack of documentation with Server Sent Events. Currently considering passing authorization data in the URL, although not a preferred method. Utilizing AngularJS and inter ...

Disconnected WebSocket in Node.js using Socket.io

Currently, I am encountering an issue. It involves a login page that leads to another page where my socket connection is disrupted. The goal I am striving for is: Within my server-side app.js app.post('/login', urlencodedParser, function(req, ...

Having issues with React-router v4's this.props.history.push() not functioning as expected

I'm attempting to programmatically redirect using the this.props.history.push(..) method, but for some reason it's not working. Here is the routing setup: import { BrowserRouter as Router, Route } from 'react-router-dom'; <Route ...

The issue of receiving a 500 error when making a POST request in node.js

I have created my own unique REST API that utilizes an NLP API internally. I need to post data on their URL, but unfortunately I am encountering an error that is causing my API to return a 500 error to the frontend. Below is a snippet of my server.js code ...

Integrating jQuery class into code snippets

I have implemented a fixed header on scroll by adding the class 'fixed' and it is working fine. When I scroll down, after 50px, the 'fixed' class is added to my header container. However, when I scroll back up, the 'fixed' cla ...

I keep receiving the same error (ENOENT) for all npm commands

Currently, I am running windows 8.1 x64 with all the latest updates installed. I encountered an error while using nodejs version 8.9.1 when running the command "npm -v". As a result, I decided to uninstall this version and switch to version 8.9.3. However ...

Opening the identical document

In my coding scenario, I am programmatically writing to a text file using Java while simultaneously attempting to read from the same file using jQuery. Unfortunately, I am encountering an issue where jQuery is unable to detect the updated content whenever ...

Guide to accessing HTML elements and saving them in a JSON formatted text using JavaScript

If you have an html form with labels, select boxes, and radio buttons, you can use javascript to store the child elements of that form in a json string format. Here is an example: { "label": { "content": "This is a label" }, "textbox" ...

The input type '{}' does not match the expected type 'Readonly<IIdeasContainerProps>'. The property '...' is not found in the type '{}'

Having recently started using TypeScript, I'm encountering some issues when attempting to execute this code snippet. Error The error message reads as follows: Failed to compile 13,8): Type '{}' is not assignable to type 'Readonly &l ...

Using Node.js to schedule and send notifications to a specific topic via FCM

In order to deliver topic notifications to Android devices using FCM, I have set up an Angular application and a Node.js server. The scheduling of these notifications is handled by the bull library. The process involves two methods of sending notification ...

When running the npm build command, Vite successfully identifies the connection with sass, yet it fails to do so when running

Utilizing the <link> tag to import a SASS/SCSS file in the Vite/VueJS 3 index file: <link rel="stylesheet" type="sass" href="/src/assets/test.scss"> Everything functions properly when I execute npm run build: the ...

Displaying complex JSON data in an HTML format using JavaScript

How can I convert the second array of entities into an HTML format from the JSON data using a for loop or similar method? To access the necessary data, I currently use console.log(data.response[0].entities.urls); $(document).ready(function () { $.getJSO ...

The addition operator cannot be used with the Number type and the value of 1

Encountering an issue where the operator '+' cannot be applied to types 'Number' and '1' buildQuerySpec() { return { PageSize: this.paging.PageCount, CurrentPage: this.paging.PageIndex + 1, MaxSize: '' ...

utilizing AJAX to retrieve scripts from WITHIN my own domain

In the realm of ajax scripts, I encounter a scenario where referencing something within the same domain requires passing HTML and associated javascript. Due to it being a non X-domain setup, I anticipate that this could be achievable. The aim here is to fe ...