mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-15 01:41:42 +00:00
capturar el evento de envío del formulario closes #231
This commit is contained in:
parent
6467f6b09c
commit
69f1687962
2 changed files with 6 additions and 7 deletions
|
@ -1,11 +1,10 @@
|
||||||
document.addEventListener('turbolinks:load', () => {
|
document.addEventListener('turbolinks:load', () => {
|
||||||
// Al enviar el formulario del artículo, aplicar la validación
|
// Al enviar el formulario del artículo, aplicar la validación
|
||||||
// localmente y actualizar los comentarios para lectores de pantalla.
|
// localmente y actualizar los comentarios para lectores de pantalla.
|
||||||
document.querySelectorAll('.submit-post').forEach(submit => {
|
document.querySelectorAll('form').forEach(form => {
|
||||||
submit.addEventListener('click', event => {
|
form.addEventListener('submit', event => {
|
||||||
const form = submit.closest('form')
|
const invalid_help = form.querySelectorAll('.invalid-help')
|
||||||
const invalid_help = form.querySelectorAll('.invalid_help')
|
const sending_help = form.querySelectorAll('.sending-help')
|
||||||
const sending_help = form.querySelectorAll('.sending_help')
|
|
||||||
|
|
||||||
invalid_help.forEach(i => i.classList.add('d-none'))
|
invalid_help.forEach(i => i.classList.add('d-none'))
|
||||||
sending_help.forEach(i => i.classList.add('d-none'))
|
sending_help.forEach(i => i.classList.add('d-none'))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
.form-group
|
.form-group
|
||||||
= submit_tag t('.save'), class: 'btn submit-post'
|
= 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'))
|
= 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'))
|
= site.config.fetch('sending_help', t('.sending_help'))
|
||||||
|
|
Loading…
Reference in a new issue