bluenevus commited on
Commit
8f18b64
·
verified ·
1 Parent(s): 4d5516b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -68,7 +68,7 @@ app.layout = dbc.Container([
68
  dbc.Col([
69
  html.H2("My URL App", className="mt-3 mb-4"),
70
  dbc.Button("Add URL", id="open-modal-button", color="primary", className="mb-3"),
71
- html.Div(id='url-list', children=generate_url_list(get_links())),
72
  ], width=3, className="bg-light p-3"),
73
  dbc.Col([
74
  html.Iframe(
@@ -93,14 +93,23 @@ def toggle_modal(n1, n2, is_open):
93
  return is_open
94
 
95
  @callback(
96
- [Output('url-list', 'children'),
 
 
 
 
 
 
 
 
97
  Output('add-url-feedback', 'children'),
98
  Output('add-url-status', 'data')],
99
  [Input('add-url-button', 'n_clicks'),
100
  Input('add-url-status', 'data'),
101
  Input({'type': 'delete-button', 'index': dash.ALL}, 'n_clicks')],
102
  [State('new-url-name', 'value'),
103
- State('new-url-link', 'value')]
 
104
  )
105
  def update_url_list(add_clicks, status, delete_clicks, new_name, new_link):
106
  ctx = dash.callback_context
 
68
  dbc.Col([
69
  html.H2("My URL App", className="mt-3 mb-4"),
70
  dbc.Button("Add URL", id="open-modal-button", color="primary", className="mb-3"),
71
+ html.Div(id='url-list'), # We'll populate this with a callback
72
  ], width=3, className="bg-light p-3"),
73
  dbc.Col([
74
  html.Iframe(
 
93
  return is_open
94
 
95
  @callback(
96
+ Output('url-list', 'children'),
97
+ Input('url-list', 'id')
98
+ )
99
+ def initialize_url_list(id):
100
+ links = get_links()
101
+ return generate_url_list(links)
102
+
103
+ @callback(
104
+ [Output('url-list', 'children', allow_duplicate=True),
105
  Output('add-url-feedback', 'children'),
106
  Output('add-url-status', 'data')],
107
  [Input('add-url-button', 'n_clicks'),
108
  Input('add-url-status', 'data'),
109
  Input({'type': 'delete-button', 'index': dash.ALL}, 'n_clicks')],
110
  [State('new-url-name', 'value'),
111
+ State('new-url-link', 'value')],
112
+ prevent_initial_call=True
113
  )
114
  def update_url_list(add_clicks, status, delete_clicks, new_name, new_link):
115
  ctx = dash.callback_context