From f07f760ef29f0fae0a0e36a7011302a4b3291af3 Mon Sep 17 00:00:00 2001 From: gabrielgiroe1 Date: Wed, 24 Jan 2024 16:38:30 +0200 Subject: [PATCH] Refresh turbo frame for turboFrameIdValue --- .../js/controllers/has_many_refresh_controller.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/javascript/js/controllers/has_many_refresh_controller.js b/app/javascript/js/controllers/has_many_refresh_controller.js index a18ab57bdc..0bd378627d 100644 --- a/app/javascript/js/controllers/has_many_refresh_controller.js +++ b/app/javascript/js/controllers/has_many_refresh_controller.js @@ -1,7 +1,18 @@ import { Controller } from "@hotwired/stimulus"; export default class extends Controller { - connect() { - console.log("Heeere!!!"); + static values = { + turboFrameId: String, + }; + + refresh() { + var element = document.getElementById(this.turboFrameIdValue); + if (element) { + element.reload(); + } else { + console.error( + "Element with ID '" + this.turboFrameIdValue + "' not found." + ); + } } }