Is there any events or components that will fire a callback when the page is being loaded

I want to read from database and initialize some dropdown lists according to the result from database. And that will be done when the page is being loaded or refreshed (F5). Is there any events or components that will fire a callback when the page is being loaded or refreshed?

1 Like

You don’t need a call back for this if your drop-down is not dynamic. You can directly read the database into a list & from the list to drop-down.

When you load the app, the drop-down will get automatically populated.

If your drop-down is dynamic, then you need a callback but you need to input something into callback. What will be this in your case?.

If you set app.layout to be a function, then it will be called whenever the app is loaded or refreshed. See Live Updates | Dash for Python Documentation | Plotly for more details.

@chriddyp Sorry for late reply because of a travel. That’s awesome! How can I miss it… The app.layout is actually a special callback which is so powerful that is having control to all the components in the page. I can dynamically initialize any components I want.
BTW, for a normal dash callback, it seems only ONE output can be assigned to it. Sometimes my application wants to change two or more output according to a input list or events. Now I have to write multiple callbacks with each output. Is there a faster way to bind multiple output to a single callback?

1 Like

There is not right now. You can see some other approaches in this issue comment here: Add reactive expressions / blocks · Issue #49 · plotly/dash · GitHub

Thanks for the direction @chriddyp

@chriddyp hi! First of all, thanks for Dash. It is an amazing tool. :slight_smile:
As you know, many features(like the one mentioned on this thread) are missing and my project is growing bigger.
Therefore, I wanted to ask you if is there any major release on the way?

Again thanks for Dash.
Best regards