dcc.Loading - target_components

Hi all,

I have a small question regarding dcc.Loading component. I’m exploring the usage of target_components to control what triggers the loading state.

We are working with dict id’s for pattern-matching callbacks, like:
{"id": "page-1", "type":"grid"}

However, how would I be able to use this in the target_components prop of dcc.Loading?

I tried working with a json.dumps(id), or passing the dict directly, but none of them work right now → loading state is not activated.

minimal example:

id_grid = {"id": "page-1", "type":"grid"}
dcc.Loading(
  children=dag.agGrid(id=id_grid)
  target_component={json.dumps(id_grid), "rowData"}
)

Hi @jankrans

Dash uses a JavaScript function to turn the dict ids into strings. You can find more info on how to do that in Python in this post Finding dictionary Ids in the Dom - #3 by simon-u

1 Like

try stringify_id(id):

from dash._utils import stringify_id
3 Likes