I have being fighting with this issue for a couple of days now, I'm using eval()
to declare some variables that come from firebase. I want to make a clickable url that might allow me to select between different files of the DB.
function Versiones(doc) {
Layout_02.innerHTML += `
<p id="${doc.id}"> Id= ${doc.id} </p>
<p> OT= ${doc.data().OT} </p>
<p> Entrega= ${((doc.data().Entrega).toDate()).toDateString()} </p>
<p> Registrado= ${((doc.data().Generada).toDate()).toDateString()} </p> `;
eval(`const ${doc.id} = document.getElementById("${doc.id}");`);
eval(`${doc.id}.addEventListener("click", ()=>{Documento(${doc.id})});`);
}
function Documento(doc) {
console.log("Recibido: ");
console.log(doc.id);
}
The thing is that, just the last paragraph actually have a click event associated, the other paragraphs doesn't have. Can you help me understand what is happening ?
I have tried changing the variable type, and using onclick
event. but nothing works.
Thanks.