Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple outputs in a single callback #80

Closed
ibdafna opened this issue Jul 12, 2017 · 2 comments
Closed

Multiple outputs in a single callback #80

ibdafna opened this issue Jul 12, 2017 · 2 comments

Comments

@ibdafna
Copy link

ibdafna commented Jul 12, 2017

Seeing this is not supported. Is there a workaround where I could have two outputs in a single callback?

For example:

x = html.Div(id='div-1', children=[pandas_table])
y = html.Div(id='div-2', children=[html.P('status_bar')])

In the callback, I'd like to amend it so that once the function executes, x and y would be assigned different values depending on if statements such as:

if condition:
return render_pandas_table), html.P('Update successful')

where the order of returned items refers to the output's object I'm looking to modify.

Thanks!

@chriddyp
Copy link
Member

You could set up a callback function to return a different set of components. For example:

app.layout = html.Div([
    dcc.RadioItems(id='radio', value='x', options=[{'label': i, 'value': i} for i in ['x', 'y', 'z']])
    html.Div(id='output')
])

@app.callback(Output('output', 'children'), [Input('radio', 'value')])
def update_content(value):
    if value == 'x':
        return [html.Div('X was selected')]
    elif value == 'y':
        return [html.Div('Y was selected')]
    elif value == 'z':
        return [html.Div('Z was selected')]

that function can return any combination of components.

Does that help?

@ibdafna
Copy link
Author

ibdafna commented Aug 9, 2017

This works, nice idea! Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants