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)