From 693b27d62e39287f71680224c4b6c2f6861da796 Mon Sep 17 00:00:00 2001 From: Marc Doerflinger Date: Sat, 15 Jun 2024 20:48:24 +0000 Subject: [PATCH] fix favorite icon update (closes #477) --- app/javascript/controllers/recipe_controller.js | 11 +++++++---- app/views/recipes/show.html.erb | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/javascript/controllers/recipe_controller.js b/app/javascript/controllers/recipe_controller.js index dd2821d0..de31e9ad 100644 --- a/app/javascript/controllers/recipe_controller.js +++ b/app/javascript/controllers/recipe_controller.js @@ -3,8 +3,9 @@ import { Utils } from "../src/utils" export default class extends Controller { static targets = ["deleteButtons", - "imagelg", "imagebox", "imagefulllink" - ] + "imagelg", "imagebox", "imagefulllink", + "favoriteicon", + ]; delete() { var url = this.data.get("url"); @@ -46,9 +47,11 @@ export default class extends Controller { }, }).then(function json(response) { return response.json() - }).then(function(data) { - Turbolinks.visit(data.redirect_url); }); + // toggle heart icon + var favoriteIcon = this.favoriteiconTarget; + favoriteIcon.classList.toggle("far"); + favoriteIcon.classList.toggle("fas"); } imageLgShow(event) { diff --git a/app/views/recipes/show.html.erb b/app/views/recipes/show.html.erb index 5c78eb4b..66016149 100644 --- a/app/views/recipes/show.html.erb +++ b/app/views/recipes/show.html.erb @@ -81,9 +81,9 @@