I would like to prevent users from being able to submit forms multiple times in my application. I built a directive that will disable the button once it has been clicked which works fine, however the button stays disabled when the form submission fails and I'm not sure how to resolve that.
The problem scenario: A user fills out the form and clicks submit. The button is disabled to prevent additional clicks. function ig(eos, δ, τ)
end_ = Σ(eos.n₀[4:8] .* log.(1-exp.(-eos.γ₀)*τ))
return log(δ) + eos.n₀[1] + eos.n₀[2]*τ + eos.n₀[3]*log(τ) + end_
end
makes a df.to_sql(con=db, name='rsstracker', if_exists='append', flavor='mysql')
request to an API which returns a response with a code outside of the 200's. My code will then look at the error, determine what went wrong, and set validation errors on the form so the user can correct the issue then try again.
However the directive has no idea what happened after the button was disabled and has no way of knowing it needs to be enabled now to allow the user to submit the form again.
import pymysql
from sqlalchemy import create_engine
engine = create_engine('mysql+pymysql://<username>:<password>@<host>[:<port>]/<dbname>')
engine.execute("DROP TABLE IF EXISTS rsstracker")
engine.execute("""CREATE TABLE rsstracker(
article_title varchar(255),
article_url varchar(1000),
article_summary varchar(1000))""")
df.to_sql(con=engine, name='rsstracker', if_exists='append', , flavor='mysql')