Button that shows modal for each b-table row
The problem is that:
- You're rendering a modal for each row of the table and;
- Reading the docs, it seems like the modal is triggered by the id, and your b-modal id is not dynamic depending on the row.
How to fix it:
- Use just one modal on the
b-table
level - Dynamically inject id into your
modal_edit-subnet
component:
<template> <div> <b-button size="sm" v-b-modal[id]>Edit</b-button> <b-modal :id="id" ref="modal" title="Edit subnet" @ok="handleOk" > This is subnet {{data_subnet.id}} </b-modal> </div></template><script>export default { props: { id: { type: String | Number } }}</script>
- Use v-model (this is the way I would do it)
<template> <div> <b-button size="sm" @click="show = true">Edit</b-button> <b-modal v-model="show" ref="modal" title="Edit subnet" @ok="handleOk" > This is subnet {{data_subnet.id}} </b-modal> </div></template><script>export default { data() { return { show: false } }}</script>