Let’s say I have a list of A-elements on my site that should each execute the same callback when being pressed, while providing their ID so I know which elements has been clicked. The length of this list is dynamic and can potentially contain 100 elements.
My first bet was something like this:
@app.callback(Output('description', 'children'),
[Input('res-'+str(i), 'n_clicks') for i in range(num)])
where num is the number of links in that list. This way I can detect the clicks but I don’t know which element has been clicked and I don’t know how to define the header of the following Python function to accept a dynamic number of parameters.
Another idea is to use the parent element as an Input and create a second callback that would add an .active HTML class to the clicked list element. Would that work?
Any other ideas? Maybe I’m not seeing the obvious solution here
Thanks,
pietz