18 lines
467 B
TypeScript
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);
|
|
});
|
|
}
|
|
}
|