Learn how to use Dash Bio for next-gen sequencing & quality control. 🧬 Access the recorded webinar.

Is there a way to trigger load on initial page load only and not every time a change is made to the page?

My page content is wrapped in a parent Loading component that gets triggered every time a change is made to the page. I only want this Loading component to be triggered on the initial page load only. How do I go about doing that?

1 Like

AFAIK there is no simple way to do it for now… Here is a discussion that might be helpful, but I never tested it.

1 Like

You could possibly do the following:

Ctx=dash.callback_context

Generally on page load the callback is fired because the component is initialized not necessarily the input has a value. So check the ctx.triggered[0][‘value’]. If it’s none then do something, if it is a value then return dash.no_update. That will keep the callback from changing the output.

1 Like

Another approach would be to create a dummy div somewhere on the page, with no contents, and set up your callback to to have an input from the children of that dummy div. Since the div will never have any children, the call back will only get triggered on page load and never again.

Hope that helps.

2 Likes

Thank you for the reply. I ended up going with this approach.