From 5270ee671b1e2bfb685330cfc339aad080aa5054 Mon Sep 17 00:00:00 2001 From: hay-kot Date: Sun, 25 Apr 2021 13:20:27 -0800 Subject: [PATCH] fix ingredient checkbox --- .../Recipe/RecipeViewer/Ingredients.vue | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/frontend/src/components/Recipe/RecipeViewer/Ingredients.vue b/frontend/src/components/Recipe/RecipeViewer/Ingredients.vue index 0014966db..7dc46343b 100644 --- a/frontend/src/components/Recipe/RecipeViewer/Ingredients.vue +++ b/frontend/src/components/Recipe/RecipeViewer/Ingredients.vue @@ -3,23 +3,22 @@

{{ $t("recipe.ingredients") }}

@@ -37,18 +36,27 @@ export default { props: { ingredients: Array, }, - computed: { - displayIngredients() { - return this.ingredients.map(x => ({ - text: x, - checked: false, - })); + data() { + return { + checked: [], + }; + }, + mounted() { + this.checked = this.ingredients.map(() => false); + console.log(this.checked); + }, + watch: { + ingredients(val) { + console.log(val); }, }, methods: { generateKey(item, index) { return utils.generateUniqueKey(item, index); }, + toggleChecked(index) { + this.$set(this.checked, index, !this.checked[index]); + }, }, };