Confusing HTML form submit event
Last Modified on August 10, 2020Look at the form element and
the buttons inside it in
todo.tag,
(a riot.js example tag file).
When clicked,
the Add
button triggers submit event and
the X
button does not. None of them
are marked of type submit
.
I found that
X
button
does emit the submit event
if I remove its click handler.
I also found that the order of buttons
is immaterial to this behaviour.
It looks like click on buttons inside forms
emit submit event by default if no other
click handlers are registered.
Perhaps it is common practice to
use click
handler to
suppress submit event
and Riot.js does it.
Another quirk to remember for lazy Web Developers.