feat(javascripts): add application

This commit is contained in:
dualfroz committed 2026-09-02 20:54:16 +02:00
1 parent 8d3d29c8a7
commit 0c118fe8c9
1 file changed
+12
@@ -0,0 +1,12 @@
// Rails-UJS-lite: any element with a data-confirm attribute (button_to
// destroy links generate one, see app/views/posts/_post.erb) pops a native
// confirm() dialog before its click is allowed to reach the form submit;
// cancelling the dialog cancels the click.
document.addEventListener("click", function (event) {
var target = event.target.closest("[data-confirm]");
if (!target) return;
if (!window.confirm(target.getAttribute("data-confirm"))) {
event.preventDefault();
event.stopPropagation();
}
});