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:
Emi Matchu 2024-09-20 18:55:08 -07:00
parent 3bd6f09a54
commit f20a1b5398

View file

@ -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();
}); });