I have a clickable image gallery that creates some preview thumbnail.
[
html.A(id=_id, children=html.Img(src=src, height=300, id=image_id, style={'margin': '10px'}))
,… ]
which are dynamically inserted in a Div. The first images ‘clicked’ callback fires when the list is generated.
Which then forces another element to load some content. The user can now change or delete an image which updates the thumbnails. Though, then the first image sends a click again. The problem is that the image was never clicked and now forces the other elements to load something completely wrong. Is it possible to prevent that from happening?
I tried
@app.callback(
Output('pko-image-clicked-output', 'children'),
[Input({'type': 'image', 'index': ALL}, 'n_clicks')],
prevent_initial_call=True
)
def pko_image_clicked(ndx):
if ndx is None or len(ndx)==0: raise PreventUpdate
ctx = dash.callback_context
clicked = ctx.triggered[0]['prop_id']
clicked = clicked.replace('{"index":"', '')
clicked = clicked.split('","type":')[0].replace('\\', '')
print('Clicked:', clicked)
return clicked
which did not work. I have a multi page app which requires:
app.config['suppress_callback_exceptions'] = True
1 post - 1 participant