Open cpsievert opened 2 years ago
For posterity, with Shiny>1.7.4, one can workaround this issue by adding this right after registering the binding (as was done in https://github.com/rstudio/py-shinywidgets/pull/91)
Shiny.shinyapp.taskQueue.enqueue(() => Shiny.bindAll(document.body));
Update: see version in https://github.com/rstudio/py-shinywidgets/pull/93
I think it can actually be simplified to:
Shiny.shinyapp?.taskQueue?.enqueue(() => Shiny.bindAll(document.body));
Consider a basic input binding:
Now, if we register synchronously all is fine, but not if we register in a
setTimeout()
, the binding doesn't bind to the DOM:That use case may seem contrived, but becomes a real problem if you're trying to load JS dependencies asynchronously (e.g., via requirejs) to define/register the binding: