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?
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 https://plot.ly/dash/live-updates 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?
There is not right now. You can see some other approaches in this issue comment here: https://github.com/plotly/dash/issues/49#issuecomment-311511286
Thanks for the direction @chriddyp