Skip to content

Callback is not registered, when multiple callbacks have the same output #163

@cserteGT3

Description

@cserteGT3

I'm having an issue, where two callbacks have the same output, but one of them is not registered.
Example code is below, tested with Dash v1.1.1, Julia 1.7.2 (on Windows).

With the below code running, I can click on button1, but it doesn't do anything. If I check the callbacks in the browser (using debug mode), button1 is not even on the graph, only button2 is shown.
If I change the order in the code, then button2 is not working, so my guess is, that the latest (in the code) is kept.
Should my concept (two callbacks with the same output chained to a new callback) even work or is that an edge case, that haven't been found yet?

I hope my description is understandable and my MWE is minimal enough. If not, I'm happy to provide any more details.

using Dash

app = dash()

dfc = [Dict("name" => "c$i", "id" => "c$i") for i in 1:5]
dfd = [Dict(("c$j"=> rand()) for j in 1:5) for i in 1:7]

app.layout = html_div() do
    html_h1("Test table"),
    dash_datatable(
        id="table",
        columns=dfc,
        data = dfd,
    ),
    html_button("button 1", id="button-1"),
    html_button("button 2", id="button-2"),
    html_div(id = "id-string", children=""),
    html_div(id = "id-string2", children="")
end

# button 1
callback!(
	app,
	Output("id-string", "children"),
	Input("button-1", "n_clicks")
) do buttonvalue
	return "Button 1: $buttonvalue."
end

# button2
callback!(
	app,
	Output("id-string", "children"),
	Input("button-2", "n_clicks")
) do buttonvalue
	return "Button 2: $buttonvalue."
end

# callback based on result of button2 and button1
callback!(
	app,
	Output("id-string2", "children"),
	Input("id-string", "children")
) do stringval
	return "Common button callback: $stringval"
end

run_server(app, "0.0.0.0", 8050, debug=true)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions