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 {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue