mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 21:29:38 +02:00
21 lines
565 B
JavaScript
21 lines
565 B
JavaScript
|
import { Controller } from "@hotwired/stimulus";
|
||
|
|
||
|
// Connects to data-controller="selectable-link"
|
||
|
export default class extends Controller {
|
||
|
connect() {
|
||
|
this.element.addEventListener("change", this.handleChange.bind(this));
|
||
|
}
|
||
|
|
||
|
disconnect() {
|
||
|
this.element.removeEventListener("change", this.handleChange.bind(this));
|
||
|
}
|
||
|
|
||
|
handleChange(event) {
|
||
|
const paramName = this.element.name;
|
||
|
const currentUrl = new URL(window.location.href);
|
||
|
currentUrl.searchParams.set(paramName, event.target.value);
|
||
|
|
||
|
Turbo.visit(currentUrl.toString());
|
||
|
}
|
||
|
}
|