Following is the code snippet and callback is getting triggered but the prop_id and value are coming ‘.’ and None respectively after button click in dash.callback_context.triggered. The objective is to get the button value i.e. button text on click and set it to the input tag value with the menu-option-value id in the callback.
Kindly help me out.
Thanks!
import dash
import dash_html_components as html
import dash_core_components as dcc
import dash_bootstrap_components as dbc
from dash.dependencies import Input, Output, State
app = dash.Dash(__name__)
app.layout = html.Div(className='main-body',children=[
html.Div(className='menu', children=[
html.Ul(children=[
html.Li(className='menu-option', children=[
html.A(className='menu-option-btn', href='#', children=[
html.Img(src='./assets/icons/chart-area.svg', className='menu-icon'),
' Compute ',
html.Img(src='./assets/icons/caret-down.svg', className='caret-icon'),
]),
html.Div(children=[
html.Ul(className='dropdown-menu', children=[
html.Li(className='menu-items', children=[
html.Button('Memory & Wait Time Stat', id='list-value', n_clicks=0)
])
])
])
])
])
]),
dcc.Input(id='menu-option-value', value='Memory & Wait Time Stat'),
])
#Callback for getting the button value and id:
@app.callback(Output('menu-option-value', 'value'),
[Input('list-value', 'n_clicks')]
)
def list_item_value(updated_value):
ctx = dash.callback_context.triggered
print(ctx)
print(updated_value)
raise dash.exceptions.PreventUpdate
#Output:
[{'prop_id': '.', 'value': None}]
0