I need to make a dynamic “list” (generates based on an input box), but the dynamic list items must be able to be identified when clicked. I use the word “list” but it could be div’s or any other html element that can be stacked on top of one another.
I know there is no shortage of dynamic callback questions, but this one is different because the list items are generated dynamically, yet they must all be in a callback as an input. Generating the items was no issue, but when I tried creating a callback based on those list items(see below), I ended up getting a console error which mentioned that the callback had an invalid input so that is where I got stumped.
@app.callback(Output('test_out', 'children'),
[
Input(f'list-item-{key}', 'n_clicks') for key in keys
])
def cb_function(*args):
# determine the input that got triggered
ctx = dash.callback_context
list_item = ctx.triggered['id']
# remaining code that works with that input follows
I also think that this may call for a custom react component, but I’d like to leave that as a last resort since I’m the sole dev on this project and creating a javascript environment adds more overhead.