Hi guys,
I’m observing a strange behavior while using multiple outputs within a callback. The idea is to show a message if user hasn’t entered all required info. Once all data is input, save it to a database, then show message so user knows data was saved.
However, the problem is when the message of missing data triggers, it will show up 3 times using the code below. And I’ve seen that if you move the Output('confd_colleague_missing_inputs to the middle of the list (position 2) then it shows up 2 times. If you place at the end of the list (position 3) then it displays only once!
Looks like a bug to me. Can you help me understand if I’m doing something wrong here?
@app.callback([Output('confd_colleague_missing_inputs','displayed'),
Output('confd_temp','displayed'),
Output('confd_colleague_confirm_save','displayed'),
],
[Input('btn_colleague_save','n_clicks')],
[State('txt_colleagueid','value'),
State('txt_colleague_name', 'value'),
State('dropd_colleague_role', 'value')])
def btn_save_colleague(clicks, idval, nameval, roleval):
#Logic for new colleagues
if clicks == 0:
return False, False, False
else:
if idval == '':
if nameval != '' and roleval != None:
str_sql = """
INSERT INTO poc.colleagues (full_name, mck_role)
VALUES (%s,%s);
"""
print('nameval:',nameval,'roleval:',roleval)
df = pd.DataFrame({'full_name':[nameval],
'mck_role':[roleval]})
execute_sql(str_sql, 'many', df=df)
return False, False, True
else:
return True , False, False
else:
return False, False, False