fix: turbo_input js controller can accept a method in option
This commit is contained in:
parent
7d48c294d6
commit
84f301cdb8
1 changed files with 5 additions and 1 deletions
|
@ -5,10 +5,12 @@ import { ApplicationController } from './application_controller';
|
||||||
export class TurboInputController extends ApplicationController {
|
export class TurboInputController extends ApplicationController {
|
||||||
static values = {
|
static values = {
|
||||||
url: String,
|
url: String,
|
||||||
|
method: { type: String, default: 'get' },
|
||||||
loadOnConnect: { type: Boolean, default: false }
|
loadOnConnect: { type: Boolean, default: false }
|
||||||
};
|
};
|
||||||
|
|
||||||
declare readonly urlValue: string;
|
declare readonly urlValue: string;
|
||||||
|
declare readonly methodValue: string;
|
||||||
declare readonly loadOnConnectValue: boolean;
|
declare readonly loadOnConnectValue: boolean;
|
||||||
|
|
||||||
connect(): void {
|
connect(): void {
|
||||||
|
@ -22,6 +24,8 @@ export class TurboInputController extends ApplicationController {
|
||||||
const target = this.element as HTMLInputElement;
|
const target = this.element as HTMLInputElement;
|
||||||
const url = new URL(this.urlValue, document.baseURI);
|
const url = new URL(this.urlValue, document.baseURI);
|
||||||
url.searchParams.append(target.name, target.value);
|
url.searchParams.append(target.name, target.value);
|
||||||
httpRequest(url.toString()).turbo();
|
httpRequest(url.toString(), {
|
||||||
|
method: this.methodValue
|
||||||
|
}).turbo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue