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