How to know that all js from bokeh is executed

Hi I have a function in js that grabs the selected value from a dropdown widget (created with bokeh) on start. But the problem is sometimes the widget is not ready on the inital load so my


is not defined yet. What I did is a bit of a hack for now: I call the init function with a timeout

setTimeout(init, 50);

which is weird and probably not robust.

Maybe there is an event that could be used to attach a jscallback to the widget?

1 Like

If this is a Bokeh server app, then version 2.2 added a DocumentReady event that can trigger a Python callback:

curdoc().on_event(DocumentReady, ...)

If this is not a Bokeh server app (i.e., if this is just static HTML output), then there is not yet any built in option. it is still an open issue to expose DocumentReady for JS callbacks.

Thanks Bryan:

Yes this is a static html/js. I will live with my hack until this can be sorted out.