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">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
|
@ -69,8 +69,14 @@
|
|||
</div>
|
||||
{{template "partials/footer" .}}
|
||||
<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 () => {
|
||||
try {
|
||||
const text = await navigator.clipboard.readText();
|
||||
|
@ -79,6 +85,10 @@
|
|||
toastr.error("Failed to paste url from clipboard.");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
htmx.onLoad(setupPaste);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue