update buttons after click to prevent dupe actions
Ted Unangst tedu@tedunangst.com
Tue, 23 Apr 2019 11:12:17 -0400
2 files changed,
8 insertions(+),
4 deletions(-)
M
views/homepage.html
→
views/homepage.html
@@ -20,10 +20,14 @@ x.open("POST", url)
x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") x.send(data) } -function bonk(xid) { +function bonk(el, xid) { + el.innerHTML = "bonked" + el.disabled = true post("/bonk", "CSRF={{ $BonkCSRF }}&xid=" + xid) } -function zonkit(xid) { +function zonkit(el, xid) { + el.innerHTML = "zonked" + el.disabled = true post("/zonkit", "CSRF={{ $BonkCSRF }}&xid=" + xid) } </script>
M
views/honk.html
→
views/honk.html
@@ -27,8 +27,8 @@ </div>
{{ end }} {{ if and .Bonk (not (eq .Honk.What "zonked")) }} <p> -<button onclick="bonk('{{ .Honk.XID }}'); return false;"><a href="/bonk">bonk</a></button> +<button onclick="bonk(this, '{{ .Honk.XID }}'); return false;"><a href="/bonk">bonk</a></button> <button onclick="showhonkform('{{ .Honk.XID }}', '{{ .Honk.Username }}'); return false;"><a href="/newhonk">tonk</a></button> -<button onclick="zonkit('{{ .Honk.XID }}'); return false;"><a href="/zonkit">zonk</a></button> +<button onclick="zonkit(this, '{{ .Honk.XID }}'); return false;"><a href="/zonkit">zonk</a></button> {{ end }} </div>