I am having a problem with pattern-matched inputs not triggering a callback in my app.
To investigate, I created a test.py file in the same folder and used the exact code from the ToDo app on the Pattern-Matching-Callbacks man page, here.
I modified the edit_list
def to output some print statements as soon as it is called, and that worked fine.
I then swapped this Input line:
Input("add", "n_clicks"),
to this:
Input({"type": "add", "index": ALL}, "n_clicks"),
and immediately saw the same problem that I am experiencing - the callback was not called. Clicking the add button now does nothing. Here is the full modified callback (the rest of the code is identical to the original To-Do example):
@app.callback(
[
Output("list-container", "children"),
Output("new-item", "value")
],
[
Input({"type": "add", "index": ALL}, "n_clicks"),
Input("new-item", "n_submit"),
Input("clear-done", "n_clicks")
],
[
State("new-item", "value"),
State({"index": ALL}, "children"),
State({"index": ALL, "type": "done"}, "value")
]
)
def edit_list(add, add2, clear, new_item, items, items_done):
triggered = [t["prop_id"] for t in dash.callback_context.triggered]
print(dash.callback_context.triggered)
print('triggered: ', triggered)
print('items_done: ', items_done)
print('items: ', items)
adding = len([1 for i in triggered if i in ("add.n_clicks", "new-item.n_submit")])
... etc (no further changes) ...
My requirements.txt file (note that the imports in test.py remain the same as in the original ToDo app):
dash==1.20.0
dash_core_components
dash_html_components
dash_bootstrap_components
dash-extensions==0.0.53
plotly==4.14.1
pandas==1.1.5
numpy===1.19.3
ipywidgets==7.5.1
statsmodels==0.12.1
scikit-learn==0.23.2
matplotlib==3.3.3
scipy==1.5.4
mariadb==1.0.5
gunicorn==20.0.4