I'm trying to solve my assignment in NodeJs and Electron, I have an array of data in Main.js file and retrieve it to the index.html using IPC methods. There are also a button in every record/row of data and I want to set a function on this button by onclick attribute. But this gives me error when I clicked the button that function is not defined. My Code:
function myfun(){
console.log("not working");
}
ipc.send("requestFileData");
ipc.on("responseFileData",(event,data)=>{
// var htmldata = "";
data.forEach(myFiles => {
contentsTable.append(`
<tr id="${myFiles.id}">
<td>${myFiles.id}</td>
<td>${myFiles.file_name}</td>
<td><button id="${myFiles.id}" onclick="myfun()">Edit Image</button></td>
</tr>
`);
});
});
when I clicked on the Edit Image button this gives me error:
Uncaught ReferenceError: myfun is not defined at HTMLButtonElement.onclick (index.html:1)