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

Callbacks not being executed using DashProxy when embedding dash app #240

Open
jmpaya opened this issue Feb 16, 2023 · 1 comment
Open

Comments

@jmpaya
Copy link

jmpaya commented Feb 16, 2023

Hi,

We are developing a dash application that needs to be embedded on another web application using the dash-embedded-component from Dash Enterprise.

Also, we are using DashProxy to enable us to use some built-in transforms of this library. We have realised that the callbacks work properly when accessing the app directly through Dash Enterprise, but not when it is embedded into another website.

It looks like there is some incompatibility between DashProxy and Dash Embedded Component. Using the simple example below, the callback is not being called, but changing DashProxy for Dash makes it work. Would you mind helping us with this?

from dash import Dash, html, Input, Output
from dash_extensions.enrich import DashProxy
from dash_embedded import Embeddable

app = DashProxy(__name__, plugins=[Embeddable(origins=[r'^.+dash.tests(:\d+)?'])])
server = app.server  # expose server variable for Procfile

app.layout = html.Div([
    "Press button to execute callback",
    html.Button("Click me!", id="button"),
    html.Div(id="my-div")
])

@app.callback(Output('my-div', 'children'),
              [Input('button', 'n_clicks')])
def update_graph(n_clicks):
    return f"You have clicked the button {n_clicks} times"

if __name__ == '__main__':
    app.run_server(debug=True)
dash==2.7.1
gunicorn==20.0.4
dash-extensions==0.1.8
dash-embedded==2.0.0

Screenshot of the application and its network calls when callback is working (you can see that an extra request is made):
image
image

Screenshot of the application when callback is not working:
image
image

@emilhe
Copy link
Owner

emilhe commented Feb 16, 2023

It's probably related to the app initialization being different when using the Embeddable plugin, causing the callback transformation to not being invoked correctly. Unfortunately, I don't have access to Dash Enterprise, so I am not able to help.

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