demarches-normaliennes/app/javascript/controllers/autosubmit_controller.ts
2022-10-31 16:12:02 +01:00

18 lines
467 B
TypeScript

import { ApplicationController } from './application_controller';
import { toggle } from '@utils';
export class AutosubmitController extends ApplicationController {
static targets = ['form', 'spinner'];
declare readonly formTarget: HTMLFormElement;
declare readonly spinnerTarget: HTMLElement;
submit() {
this.formTarget.requestSubmit();
}
connect() {
this.onGlobal('turbo:submit-start', () => {
toggle(this.spinnerTarget);
});
}
}