I apologize in advance if this is a stupid question am new to JavaScript and Electron.js.
In this example, I have Btn1, Btn2, Btn3 and each button is linked to a specific variable.
An onclick event listener for each button all connect to the same function and or array.
Depending on the button which was clicked, it will run that function using the variable linked to the button that was pressed.
let buttons = [btn1, btn2, btn3]
let open = document.getElementById('Btn1')
open.addEventListener('click', (event) =>{
let btn1_value = 1
//2 more of these for each button
})
}
I am not just having a set of preset functions or a series of if-case statements.
As I am trying to dynamically allow a user to add buttons to my software with using the same function.
However, using different data (files in this case) stored in a array.
I have decided to try a method like this due to my current knowledge.
It is more manageable (for me) to add and remove data from an array, using push() and pop().
Than having to create multiple functions for each button created, especially dynamically.
Any help or direction is greatly appreciated.