Skip to content

Commit

Permalink
small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
lazaronixon committed Mar 10, 2022
1 parent a15d0ea commit 658e8e9
Showing 1 changed file with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,30 @@
<script>
document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll(".field_with_errors").forEach((element) => {
const field = element.firstChild;
field.classList.add("is-invalid");
element.firstChild.classList.add("is-invalid");

element.parentNode.insertBefore(field, element);
element.parentNode.insertBefore(element.firstChild, element);
element.parentNode.removeChild(element);
})
});
});
</script>

<!--
###########################################################################################################################
Old school stimulus example
<div data-controller="toasts" data-toats-type="notice" data-toasts-message="User created successfully"></div>
###########################################################################################################################
-->
<!--
<script>
document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll("[data-controller='toasts']").forEach((thiz) => {
if (thiz.dataset["toastsType"] === "notice") {
$(document).Toasts("create", { body: thiz.dataset["toastsMessage"], class: "bg-success", title: "Success", autohide: true, delay: 7000 })
} else (thiz.dataset["toastsType"] === "alert") {
$(document).Toasts("create", { body: thiz.dataset["toastsMessage"], class: "bg-danger", title: "Error", autohide: true, delay: 7000 })
}
})
})
</script>
-->

0 comments on commit 658e8e9

Please sign in to comment.