Hi Guys,
I have multiple dropdown menu, I want the loading on those dropdown until all the options have been loaded for its and above dropdowns.
I am using dcc.Loading target_components property but unable to achieve the same.
I am using dash==2.18.2.
Layout::
app = dash.Dash(__name__)
app.css.config.serve_locally = True
app.config.suppress_callback_exceptions = True
layout = html.Div(
[
dbc.Row(
[
dbc.Col(
[
dcc.Loading(
[
dcc.Dropdown(
["New York City", "Montreal", "San Francisco"],
multi=True,
id="dd-1",
)
],
id='loading-1'
)
]
),
dbc.Col(
[
dcc.Loading(
[
dcc.Dropdown(
["New York City", "Montreal", "San Francisco"],
multi=True,
id="dd-2",
)
],
id='loading-2',
color='#c00',
target_components={
"dd-2": "options"
}
)
]
),
dbc.Col(
[
dcc.Loading(
[
dcc.Dropdown(
["New York City", "Montreal", "San Francisco"],
multi=True,
id="dd-3",
)
],
id='loading-3',
color='#c00',
target_components={
"dd-2": "options"
}
)
]
),
dbc.Col(
[
dcc.Loading(
[
dcc.Dropdown(
["New York City", "Montreal", "San Francisco"],
multi=True,
id="dd-4",
)
],
id='loading-4'
)
]
),
dbc.Col(
[
dcc.Loading(
[
dcc.Dropdown(
["New York City", "Montreal", "San Francisco"],
multi=True,
id="dd-5",
)
],
id='loading-5'
)
]
),
]
)
]
)
app.layout = html.Main([layout])
if __name__ == "__main__":
app.run_server(debug=True)
callback file::
from dash import html, dcc
import dash_bootstrap_components as dbc
from dash import Output, Input
import plotly.express as px
import dash
import time
@dash.callback(
Output("dd-2", "options"),
[Input("dd-1", "value")]
)
def test_1(values):
print(f"test_1: values => {values}")
time.sleep(5)
op = ["New York City", "Montreal", "San Francisco"]
return op