demarches-normaliennes/app/javascript/controllers/autosubmit_controller.ts

19 lines
467 B
TypeScript
Raw Normal View History

2022-10-27 17:07:18 +02:00
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);
});
}
}