From 6b6077f3cc751e4baa24d9d7694545d961e4fc9c Mon Sep 17 00:00:00 2001 From: f Date: Thu, 11 Jul 2024 19:19:05 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20avisar=20que=20se=20va=20a=20recargar=20?= =?UTF-8?q?la=20p=C3=A1gina=20cuando=20hay=20cambios=20en=20modales?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/posts/_htmx_form.haml | 4 ++-- app/views/posts/modal.haml | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/views/posts/_htmx_form.haml b/app/views/posts/_htmx_form.haml index 75967a40..1c3cc783 100644 --- a/app/views/posts/_htmx_form.haml +++ b/app/views/posts/_htmx_form.haml @@ -30,8 +30,8 @@ 'hx-target': "##{pluck_param(:target)}", 'hx-validate': true, data: { - controller: 'form-validation', - action: 'form-validation#submit', + controller: 'unsaved-changes form-validation', + action: 'unsaved-changes#submit form-validation#submit beforeunload@window->unsaved-changes#unsaved turbolinks:before-visit@window->unsaved-changes#unsavedTurbolinks', 'form-validation-submitting-id-value': pluck_param(:submitting, optional: true), 'form-validation-invalid-id-value': pluck_param(:invalid, optional: true), } diff --git a/app/views/posts/modal.haml b/app/views/posts/modal.haml index 2174595c..14836118 100644 --- a/app/views/posts/modal.haml +++ b/app/views/posts/modal.haml @@ -31,6 +31,12 @@ options[:class] += ' edit' end + data = {} + data[:controller] = 'unsaved-changes form-validation' + data[:action] = 'unsaved-changes#submit form-validation#submit beforeunload@window->unsaved-changes#unsaved turbolinks:before-visit@window->unsaved-changes#unsavedTurbolinks' + + options[:data] = data + %div{ id: modal_id, data: { controller: 'modal' }} = render 'bootstrap/modal', id: modal_id, modal_content_attributes: { class: 'h-100' } do - content_for :"#{modal_id}_body" do