mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-14 17:31:42 +00:00
deshabilitar el botón de publicación una vez que se lo toca
This commit is contained in:
parent
af3d59d34a
commit
f60fbd70f4
2 changed files with 21 additions and 3 deletions
15
app/javascript/controllers/submit_once_controller.js
Normal file
15
app/javascript/controllers/submit_once_controller.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { Controller } from 'stimulus'
|
||||
|
||||
/*
|
||||
* Deshabilita el elemento que recibe el evento, para evitar que la
|
||||
* acción se realice varias veces.
|
||||
*
|
||||
* <form data-controller="submit-once">
|
||||
* <input type="submit" data-action="submit-once#disable" />
|
||||
* </form>
|
||||
*/
|
||||
export default class extends Controller {
|
||||
disable (event) {
|
||||
event.target.disabled = true
|
||||
}
|
||||
}
|
|
@ -4,12 +4,15 @@
|
|||
tooltip: t('help.sites.enqueued'),
|
||||
text: t('sites.enqueued'),
|
||||
type: 'secondary',
|
||||
link: nil
|
||||
link: nil,
|
||||
disabled: true
|
||||
- else
|
||||
= form_tag site_enqueue_path(site),
|
||||
method: :post, class: 'form-inline inline' do
|
||||
method: :post,
|
||||
data: { controller: 'submit-once' },
|
||||
class: 'form-inline inline' do
|
||||
= button_tag type: 'submit',
|
||||
class: 'btn no-border-radius',
|
||||
title: t('help.sites.enqueue'),
|
||||
data: { toggle: 'tooltip' } do
|
||||
data: { action: 'submit-once#disable' } do
|
||||
= t('sites.enqueue')
|
||||
|
|
Loading…
Reference in a new issue