Hey All,
Even I wanted an answer for the above question, however currently I’m using a different solution and i’m able to fix the issue as of now. My test case is different from the above but I was able to reset the n_clicks. Try the below code,
import dash
import dash_core_components as dcc
import dash_html_components as html
import dash_table
from datetime import datetime as dt
table_main_style_1 = {‘text-align’:‘center’,‘border’:‘0’,‘align’:‘wrap’,‘font-size’:‘14px’}
table_main_style_2 = {‘text-align’:‘center’,‘border’:‘0’,‘vertical-align’:‘top’,‘font-size’:‘14px’}
app = dash.Dash(name)
app.config.suppress_callback_exceptions = True
app.layout = html.Div(
id=‘main-div’,children=[
html.Div(
dcc.Input(
id=‘test1’,
placeholder=‘Enter text’,
value=0,
disabled=False,
), style=table_main_style_2
),
html.Div(
dcc.Input(
id=‘test2’,
placeholder=‘Enter text’,
value=0,
), style=table_main_style_2
),
html.Div(
dcc.Input(
id=‘test3’,
placeholder=‘Enter text’,
value=0,
), style=table_main_style_2
),
html.Button(
‘Next’,
id=‘submit-button’,
n_clicks=0
),
html.Div(id=‘test4’,children=0,
#style={‘display’:‘None’}
),
html.Div(id=‘test5’,children=0,
#style={‘display’:‘None’}
)
])
@app.callback(
dash.dependencies.Output(‘test5’,‘children’),
[dash.dependencies.Input(‘test4’,‘children’)]
)
def test_update_incr(test4_inp):
return test4_inp
@app.callback(
[dash.dependencies.Output(‘test1’,‘disabled’),dash.dependencies.Output(‘test4’,‘children’)],
[
dash.dependencies.Input(‘submit-button’,‘n_clicks’)
],
[
dash.dependencies.State(‘test1’,‘value’),
dash.dependencies.State(‘test2’,‘value’),
dash.dependencies.State(‘test5’,‘children’)
]
)
def test_fun(n_clicks,test1_inp,test2_inp,incr):
if n_clicks > 0 and test1_inp != None and test2_inp != None:
incr_val = int(incr) + 1
return True, incr_val
@app.callback(
dash.dependencies.Output(‘submit-button’,‘n_clicks’),
[dash.dependencies.Input(‘test4’,‘children’)]
)
def reset_button(incr_value):
print(incr_value)
if incr_value > 1:
return 0
if name == ‘main’:
app.run_server(debug=False)