Skip to content

Instantly share code, notes, and snippets.

@rafaelogic
Last active February 5, 2025 00:10
Show Gist options
  • Select an option

  • Save rafaelogic/2b866975b858b182eafaa580313fbdcf to your computer and use it in GitHub Desktop.

Select an option

Save rafaelogic/2b866975b858b182eafaa580313fbdcf to your computer and use it in GitHub Desktop.
<template>
<div>
<div v-for="user in users" :key="user.id">
<user-profile-modal
:show="showModal(user.id)"
@close="toggleModal(user.id)" />
<a class="text-sm" href="#" @click.stop="toggleModal(user.id)">Show</a>
</div>
</div>
</template>
<script>
import UserProfileModal from './UserProfileModal.vue'
export default {
components: { UserProfileModal },
data() {
return {
activeModal: 0,
}
},
methods: {
showModal: function(id) {
return this.activeModal === id
},
toggleModal: function (id) {
if(this.activeModal !== 0) {
this.activeModal = 0
return false
}
this.activeModal = id
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment