Sha256: ee53d39e94256c8e87e6d25cca6c81162d1a85ec118d6c1291fbbf188f9c3f8e
Contents?: true
Size: 645 Bytes
Versions: 14
Compression:
Stored size: 645 Bytes
Contents
import {Controller} from '@hotwired/stimulus' import {useDebounce} from 'stimulus-use' // can't use controllerFactory because it seems to conflict with `useDebounce` export default class AutoSubmittableController extends Controller<HTMLFormElement> { static debounces = ['save'] static targets = ['form'] declare readonly formTarget: HTMLFormElement declare readonly formTargets: HTMLFormElement[] declare readonly hasFormTarget: boolean connect(): void { useDebounce(this) } save(): void { if (this.hasFormTarget) { this.formTarget.requestSubmit() } else { this.element.requestSubmit() } } }
Version data entries
14 entries across 14 versions & 1 rubygems