Oops, fix locale form with Turbo pageloads
Before this change, this would only work on the first pageload, and fail after doing a Turbo page navigation. Now, it works all the time!
This commit is contained in:
parent
3bd6f09a54
commit
f20a1b5398
1 changed files with 2 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
import "@hotwired/turbo-rails";
|
import "@hotwired/turbo-rails";
|
||||||
|
|
||||||
document.getElementById("locale").addEventListener("change", function () {
|
document.addEventListener("change", (e) => {
|
||||||
|
if (!e.target.matches("#locale")) return;
|
||||||
document.getElementById("locale-form").submit();
|
document.getElementById("locale-form").submit();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue