I am trying to use bootstrap-vue modal inside loop, something like:
<b-list-group-item v-for="item in items" :key="item">
<b-button v-b-modal.example-modal>{{ item }}</b-button>
<b-modal id="example-modal">
<p>{{ item }}</p>
</b-modal>
</b-list-group-item>
<script>
export default {
data() {
return {
items: [1, 2, 3, 4, 5, 6, 7],
};
},
};
</script>
Here the problem is whenever i click on one button it opens 7 modals (everyone inside the loop). For instance, if I click on button contain 3, it open all modal 1 to 7. How can I only call the modal whichever is clicked.
For you convenience here is codesandbox link: https://codesandbox.io/s/naughty-knuth-4q82p?file=/src/components/HelloWorld.vue:264-396
note that I need to use the modal inside the loop, because i have to pass some data to modal related to the v-for.
Thanks is advance !