diff --git a/attachments/static/attachments/js/copy_url.js b/attachments/static/attachments/js/copy_url.js
index 0ac4097..22a6ea6 100644
--- a/attachments/static/attachments/js/copy_url.js
+++ b/attachments/static/attachments/js/copy_url.js
@@ -1,5 +1,5 @@
function copy(data) {
- navigator.clipboard.writeText(data).then(() => {
+ navigator.clipboard.writeText(data.data).then(() => {
console.log("Copied");
})
}
@@ -7,14 +7,18 @@ function copy(data) {
$(document).ready(function() {
const $ = django.jQuery;
const fileUrls = $('td.field-processed_file_url, td.field-original_file_url');
+ let id = 0;
for (let fileUrl of fileUrls) {
fileUrl = $(fileUrl);
const existingText = fileUrl.text().trim();
if (!existingText) {
continue;
}
- const copyButton = `📋`;
+ const buttonId = `copy-button-${id}`;
+ const copyButton = `📋`;
let innerHTML = `${existingText} ${copyButton}`;
fileUrl.html(innerHTML);
+ $(`#${buttonId}`).on("click", null, existingText, copy);
+ id++;
}
});