Callbacks partial number of Inputs in the layout

@app.callback(Output('cards', 'children'), [Input('upload_files_to_robot_checks', 'n_clicks'), Input('back_to_project','n_clicks')])
def change_page(n_clicks_0, n_clicks_1):
	if not dash.callback_context.triggered:
		raise dash.exceptions.PreventUpdate
	
	trigger = dash.callback_context.triggered[0]
	triggered_output = trigger['prop_id']
	if triggered_output == 'upload_files_to_robot_checks.n_clicks':
		return check_list_card()
	elif triggered_output == 'back_to_project.n_clicks':
		return project_card()

In my app I let the user fill in a form when the button ‘upload_file_to_robot_checks’ is clicked different HTML content should be shown, with another button called back with id ‘back_to_project’. When this button is clicked the previous HTML code should be shown. However, this callback does not get fired…

The callback does get fired when I only implement one of the buttons

I think the cause of the callback with the two buttons not firing, is because the buttons are created dynamically. Only one of them exists at a certain moment. However, I do not get any warnings when running the code.

  1. Is my assumption correct?
  2. Is this behaviour prefered or is this a bug?

I did find this, seems that you cannot define an callback with a partial number of inputs present in the layout. Than next step is two write two callbacks. However these cannot update the same, html output…

For anybody interested, I fixed it… I used the hidden divider so all the input buttons are their on page load.

@app.callback(Output('project_card', 'hidden'), [Input('upload_files_to_robot_checks', 'n_clicks'), Input('back_to_project', 'n_clicks')])
def change_page(*args):
	if not dash.callback_context.triggered:
		raise dash.exceptions.PreventUpdate
	
	trigger = dash.callback_context.triggered[0]
	triggered_output = trigger['prop_id']
	if triggered_output == 'upload_files_to_robot_checks.n_clicks':
		return True
	if triggered_output == 'back_to_project.n_clicks':
		return False

@app.callback(Output('check_list_card', 'hidden'), [Input('upload_files_to_robot_checks', 'n_clicks'), Input('back_to_project', 'n_clicks')])
def change_page(*args):
	if not dash.callback_context.triggered:
		raise dash.exceptions.PreventUpdate
	
	trigger = dash.callback_context.triggered[0]
	triggered_output = trigger['prop_id']
	if triggered_output == 'upload_files_to_robot_checks.n_clicks':
		return False
	if triggered_output == 'back_to_project.n_clicks':
		return True
	# elif triggered_output == 'back_to_project.n_clicks':
	# 	return project_card()