fix: Attatch event listener to paste button on htmx load
This commit is contained in:
parent
75b5c4160d
commit
ffb35c3220
|
@ -1,4 +1,4 @@
|
||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html lang="en" class="h-100">
|
<html lang="en" class="h-100">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
|
@ -69,8 +69,14 @@
|
||||||
</div>
|
</div>
|
||||||
{{template "partials/footer" .}}
|
{{template "partials/footer" .}}
|
||||||
<script>
|
<script>
|
||||||
const pasteButton = document.getElementById("paste-button");
|
/**
|
||||||
const urlField = document.getElementById("url");
|
* @param content {Element}
|
||||||
|
*/
|
||||||
|
function setupPaste(content) {
|
||||||
|
const pasteButton = content.querySelector("#paste-button");
|
||||||
|
const urlField = content.querySelector("#url");
|
||||||
|
|
||||||
|
if (pasteButton) {
|
||||||
pasteButton.addEventListener("click", async () => {
|
pasteButton.addEventListener("click", async () => {
|
||||||
try {
|
try {
|
||||||
const text = await navigator.clipboard.readText();
|
const text = await navigator.clipboard.readText();
|
||||||
|
@ -79,6 +85,10 @@
|
||||||
toastr.error("Failed to paste url from clipboard.");
|
toastr.error("Failed to paste url from clipboard.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
htmx.onLoad(setupPaste);
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue