fix: turbo_input js controller can accept a method in option

This commit is contained in:
simon lehericey 2024-12-09 11:24:34 +01:00
parent 7d48c294d6
commit 84f301cdb8
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5

View file

@ -5,10 +5,12 @@ import { ApplicationController } from './application_controller';
export class TurboInputController extends ApplicationController {
static values = {
url: String,
method: { type: String, default: 'get' },
loadOnConnect: { type: Boolean, default: false }
};
declare readonly urlValue: string;
declare readonly methodValue: string;
declare readonly loadOnConnectValue: boolean;
connect(): void {
@ -22,6 +24,8 @@ export class TurboInputController extends ApplicationController {
const target = this.element as HTMLInputElement;
const url = new URL(this.urlValue, document.baseURI);
url.searchParams.append(target.name, target.value);
httpRequest(url.toString()).turbo();
httpRequest(url.toString(), {
method: this.methodValue
}).turbo();
}
}