From 8480d4ef05d995ee67c1460cf273c899fa59e89c Mon Sep 17 00:00:00 2001
From: Cristiano Magro <cristiano.magro@vola.it>
Date: Sat, 28 Dec 2024 23:15:49 +0100
Subject: [PATCH] emitting custom event

---
 07 - development setup/vue-cli-01-a-new-vue-project/src/components/FriendContact.vue |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/07 - development setup/vue-cli-01-a-new-vue-project/src/components/FriendContact.vue b/07 - development setup/vue-cli-01-a-new-vue-project/src/components/FriendContact.vue
index 3c5a041..d335955 100644
--- a/07 - development setup/vue-cli-01-a-new-vue-project/src/components/FriendContact.vue
+++ b/07 - development setup/vue-cli-01-a-new-vue-project/src/components/FriendContact.vue
@@ -1,6 +1,6 @@
 <template>
     <li>
-        <h2>{{ name }} {{ friendIsFavorite ? '(Favorite)' : '' }}</h2>
+        <h2>{{ name }} {{ isFavorite ? '(Favorite)' : '' }}</h2>
         <button @click="toggleDetails">
             {{ detailsAreVisible ? 'Hide' : 'Show' }} Details
         </button>
@@ -24,6 +24,10 @@
     //     'isFavorite'
     // ],
     props: {
+        id:{
+            title: String,
+            required: true
+        },
         name: {
             title: String,
             required: true
@@ -49,7 +53,6 @@
     data() {
         return {
             detailsAreVisible: false,
-            friendIsFavorite: this.isFavorite,
         }
     },
     methods: {
@@ -57,7 +60,8 @@
             this.detailsAreVisible = !this.detailsAreVisible;
         },
         toggleFavorite() {
-            this.friendIsFavorite = !this.friendIsFavorite;
+            // this.friendIsFavorite = !this.friendIsFavorite;
+            this.$emit('toggle-favorite', this.id);
         },
     },
 };

--
Gitblit v1.8.0