From 69f1687962a9ac38cadefb7008919f62478683f6 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 4 Feb 2021 14:03:53 -0300 Subject: [PATCH] =?UTF-8?q?capturar=20el=20evento=20de=20env=C3=ADo=20del?= =?UTF-8?q?=20formulario=20closes=20#231?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/javascripts/validation.js | 9 ++++----- app/views/posts/_submit.haml | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/validation.js b/app/assets/javascripts/validation.js index f05854f..5a48148 100644 --- a/app/assets/javascripts/validation.js +++ b/app/assets/javascripts/validation.js @@ -1,11 +1,10 @@ document.addEventListener('turbolinks:load', () => { // Al enviar el formulario del artículo, aplicar la validación // localmente y actualizar los comentarios para lectores de pantalla. - document.querySelectorAll('.submit-post').forEach(submit => { - submit.addEventListener('click', event => { - const form = submit.closest('form') - const invalid_help = form.querySelectorAll('.invalid_help') - const sending_help = form.querySelectorAll('.sending_help') + document.querySelectorAll('form').forEach(form => { + form.addEventListener('submit', event => { + const invalid_help = form.querySelectorAll('.invalid-help') + const sending_help = form.querySelectorAll('.sending-help') invalid_help.forEach(i => i.classList.add('d-none')) sending_help.forEach(i => i.classList.add('d-none')) diff --git a/app/views/posts/_submit.haml b/app/views/posts/_submit.haml index b3879fd..b21b5ff 100644 --- a/app/views/posts/_submit.haml +++ b/app/views/posts/_submit.haml @@ -1,6 +1,6 @@ .form-group = submit_tag t('.save'), class: 'btn submit-post' - .invalid_help.alert.alert-danger.d-none + .invalid-help.alert.alert-danger.d-none = site.config.fetch('invalid_help', t('.invalid_help')) - .sending_help.alert.alert-success.d-none + .sending-help.alert.alert-success.d-none = site.config.fetch('sending_help', t('.sending_help'))