@app.callback(
[Output(f"collapse-{i}", "is_open") for i in range(1, 4)]+[Output(f"collapse-card-{i}", "children") for i in range(1, 4)],
[Input(f"group-{i}-toggle", "n_clicks") for i in range(1, 4)],
[State(f"collapse-{i}", "is_open") for i in range(1, 4)]+[State(f"{i}", "children") for i in searchResults ]
)
def toggle_accordion(n1, n2, n3, is_open1, is_open2, is_open3,graph_1,graph_2,graph_3):
ctx = dash.callback_context
# print({"id": c.component_id, "property": c.component_property} for c in [State('babylon-gender-pie', "children")] )
if not ctx.triggered:
return ""
else:
button_id = ctx.triggered[0]["prop_id"].split(".")[0]
if button_id == "group-1-toggle" and n1:
return not is_open1, False, False,graph_1,None,None
elif button_id == "group-2-toggle" and n2:
return False, not is_open2, False,None,graph_2,None
elif button_id == "group-3-toggle" and n3:
return False, False, not is_open3,None,None,graph_3
return False, False, False,None,None,None
我希望每次发生回调时都使用更新的searchResult列表。
searchResult
由其他功能更新。
OR ,如果我可以使用State对象在回调之外获取子元素。