fix: modal event listener on page transition

This commit is contained in:
davidontop 2024-05-05 22:44:03 +02:00
parent a3cf31b112
commit d51e578caa
Signed by: DavidOnTop
GPG key ID: 5D05538A45D5149F

View file

@ -27,7 +27,7 @@ import Layout from "../layouts/Layout.astro";
</Layout>
<script>
document.getElementById("discord-btn").onclick = function () {
function discordOnClick () {
const modal: any = document.getElementById("discord-modal")
modal.showModal();
let inp: any = document.getElementById("discord-inp")!;
@ -35,4 +35,10 @@ document.getElementById("discord-btn").onclick = function () {
inp.select();
document.execCommand("copy");
}
document.onload = function () {
document.getElementById("discord-btn").onclick = discordOnClick;
}
document.addEventListener("astro:page-load", function () {
document.getElementById("discord-btn").onclick = discordOnClick;
})
</script>