diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-10-06 00:10:44 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-10-06 01:02:08 +0200 |
commit | cffe6351a9f8e2777b6d4c078c89bd8f215de603 (patch) | |
tree | 132b7b9be16bd53d4baa017c1eabecfaa34e5c98 /t_idea/index.html | |
parent | 08d3d9aab4845b863d868ca0e43e21c9f7f54203 (diff) |
Fixed edit function not working because js bs
Because for loop would declare a global variable, the closures would use
the el of previous scope.
Diffstat (limited to 't_idea/index.html')
-rw-r--r-- | t_idea/index.html | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/t_idea/index.html b/t_idea/index.html index f845628..97b68dd 100644 --- a/t_idea/index.html +++ b/t_idea/index.html @@ -40,24 +40,23 @@ <p><i>No ideas here... Be the first one to think!</i></p> {{ end }} </ul> - <!--template--> </body> <script> - let dels = document.querySelectorAll("form[action=\"/idea/delete/\"]") - for (el of dels) { + let dels = document.querySelectorAll("form[action=\"/idea/delete/\"]"); + for (let el of dels) { el.addEventListener("submit", function(e) { - e.preventDefault() + e.preventDefault(); if (confirm("are you sure?") === true) { - this.submit() + this.submit(); } }) } - let eels = document.querySelectorAll("button.edit") - for (el of eels) { - el.onclick = function(e) { - location.href = "/idea/edit?t=" + el.getAttribute("data-title") + let eels = document.querySelectorAll("button.edit"); + for (let el of eels) { + el.onclick = function() { + let title = el.getAttribute("data-title"); + location.href = "/idea/edit?t=" + title; } } - </script> </html> |