I am following the example on Part 5. Sharing Data Between Callbacks | Dash for Python Documentation | Plotly and have a hidden div in my layout as:
html.Div(sid, id='session_id', style={'display': 'none'}),
with sid as a randomly defined string.
I have one callback that is working great:
@app.callback(
[Output('graph-gains', 'children'),
Output('table-gains', 'children'),
Output('dps-gains', 'max_date_allowed'),
Output('dps-gains', 'initial_visible_month'),
Output('interval-gains', 'interval'),
Output('msg_dbg-gains', 'children')],
# sym, ix, date come straight from the control elements
[Input('dd_sym-gains', 'value'),
Input('dd_ix-gains', 'value'),
Input('dps-gains', 'date'),
Input('tabs-gains', 'active_tab'),
Input('session_id', 'children'),
Input('interval-gains', 'n_intervals')])
def callback_main_gains(sym, ix, date, period, sid, nint):
sid is passed as the fifth argument to my function and works correctly. However I am trying to add it into a second callback:
@app.callback(
[Output('msg-feedback', 'children'),
Output('textarea-feedback', 'value')],
[Input('button_submit-feedback', 'n_clicks')],
[State('textarea-feedback', 'value'),
State('ddm-feedback', 'label')]
)
def callback_main_feedback(n_clicks, feedback, ddm):
also works without session-id, but adding it in and adding a sid argument as follows:
@app.callback(
[Output('msg-feedback', 'children'),
Output('textarea-feedback', 'value')],
[Input('button_submit-feedback', 'n_clicks'),
Input('session_id', 'children')],
[State('textarea-feedback', 'value'),
State('ddm-feedback', 'label')]
)
def callback_main_feedback(n_clicks, sid, feedback, ddm):
return self.callback_main_feedback(n_clicks, sid, feedback, ddm)
gives me the following error when I click the page:
TypeError: callback_main_feedback() missing 1 required positional argument: 'ddm'
When I remove the sid argument, but not the Input(‘session_id’, ‘children’) Input:
@app.callback(
[Output('msg-feedback', 'children'),
Output('textarea-feedback', 'value')],
[Input('button_submit-feedback', 'n_clicks'),
Input('session_id', 'children')],
[State('textarea-feedback', 'value'),
State('ddm-feedback', 'label')]
)
def callback_main_feedback(n_clicks, feedback, ddm):
return self.callback_main_feedback(n_clicks, feedback, ddm)
It doesn’t error but behaves as if Input(‘session_id’, ‘children’)] simply isn’t there.
I have tried this in two other callbacks. One that is a mirror-image of the working example is also is working correctly. Adding it into a fourth one is not working in the manner I’ve just described,
Any ideas what I am doing wrong here?