-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[BUG] JavaScript callbacks don't trigger Python callbacks #1774
Comments
That’s correct, if you use JavaScript to set the content of the DOM directly, dash is unaware of what you did. Instead, make div2 another output of that clientside callback and include it’s text in the callback return value. |
Hmm, I see, thanks for the clarification. My motivation for framing it this way is because the JS code that I have to work with is using Promises. I know I can't return the Promise directly to Dash, so I thought I might be able to change something on the page that Dash could pick up. Is there any way to trigger Python callbacks after running JS using Promises? I'm just looking for a way to get back into the "regular" Pythonic flow of callbacks after running a bit of JS. |
Ah, got it. Promise handling is a known limitation of clientside callbacks - see #1364, it hasn't gotten to the top of the list for anyone here but it shouldn't be hard, if you want to take a stab at it we'll certainly help you get it across the finish line. I wouldn't want to look for a hack that avoids baking this into the renderer, that would have all sorts of weird consequences, maybe most importantly for you that Dash doesn't use the DOM as its source for callback inputs, it keeps a separate layout tree of simple JS objects. |
Yep, I see that. I'd love to help, but I'm afraid my knowledge of TypeScript is close to nil. In this case, I was able to work around the problem by finding a way out of the Promise and returning a value from the JavaScript callback. I'm going to close this issue because it is documented that Dash does not support Promises; here I was trying to work around the problem by directly setting the contents of a |
Python callbacks don't appear to respond to elements (at least
html.div
s) modified by a JavaScript callback.Describe your context
I'm using macOS 10.15.7 with Python 3.8.6.
This issue is independent of browser.
Describe the bug
Python callbacks don't appear to respond to elements (at least
html.div
s) set by a JavaScript callback.I'm trying to trigger Python server-side callbacks after a JavaScript client-side callback. In this case, I'm going through
div
s. (If there is a way to have the JS directly interact with adcc.Store
component, that'd be great.) I can have JS set the content of adiv
but then Python callbacks that use thatdiv
as anInput
never trigger.The basic setup is like this:
div2
ends up being set by JS as expected, but the second callback (sketcher
), never gets triggered anddiv3
keeps its initial value. It seems (to me) that Dash is unaware that the JS callback modifieddiv2
.I am not tied to this approach–going through
div
s. I just need a way to have a JS callback trigger subsequent Python callbacks. Is this possible?To be clear, if I use a regular Python callback to set
div2
instead of JS, thendiv3
also gets set.Expected behavior
I would expect the Python callback to be triggered by the JS callback.
The text was updated successfully, but these errors were encountered: