I want dynamically create a set of buttons generated by a list of strings:
keys = [ "Temp_Innen", "Temp_Außen", "Druck", "Feuchte_Innen", "Feuchte_Außen", "PH10", "PH25" ]
Those strings shall also be used in each button on the onClick event function(parameter)...
I use this to create the buttons inside the body:
d3.select('body')
.selectAll('button')
.data(keys)
.enter()
.append('button')
.text(d => d)
.attr('type', 'button');
But how can I add dynamically add each string into an function parameter that is called via onClick? I tried this but it doesnt work:
.attr('onClick',`clicked(${d => d})`);
But that does not write the strings into the clicked() parameter, instead its written unexpressed as text:
<button type="button" onClick="clicked(d => d)">Temp_Innen</button>
<button type="button" onClick="clicked(d => d)">Temp_Außen</button>
...
Is there a way to do that dynamically or should I consider writing all those buttons static in my html file?