Submit a form with javascript doesn't trigger event modifier.
See original GitHub issueVue.js version
1.0.23
Reproduction Link
http://jsbin.com/pevimajuro/edit?html,js,output
Steps to reproduce
Submit a form with javascript document.forms[0].submit();
doesn’t trigger event modifier v-on:submit.prevent
What is actually happening?
The event modifier is not triggered. The default event is.
Is this a bug ?
Some web extension auto login after filling form, but don’t seems to work with a vuejs form.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:8 (2 by maintainers)
Top Results From Across the Web
javascript - Why won't form.submit() trigger the "submit" event?
The form's onsubmit event handler (for example, onsubmit="return false;" ) will not be triggered when invoking this method from Gecko-based applications.
Read more >Form Input Bindings - Vue.js
When dealing with forms on the frontend, we often need to sync the state of form input elements with corresponding state in JavaScript....
Read more >type - Cypress Documentation
Submits a form, but does not fire synthetic click event, if there is 1 input and no submit button; Submits form and fires...
Read more >HTMLFormElement: submit event - Web APIs | MDN
Note: Trying to submit a form that does not pass validation triggers an invalid event. In this case, the validation prevents form submission...
Read more >Prevent Default and Form Events - Beginner JavaScript
More often than not, you don't want to submit the form to the server but you often want to stop the form from...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had a scenario where i wanted to submit the form outside of the form and calling this.$refs.form.submit() wouldn’t fire my saveData() function so this is my workaround…
Form HTML
Vue component method
Hopefully this helps someone. Still can be submitted via $refs.form.submit() but I can still manually trigger the Validity (although I’m not sure if reportValidity() is reliable).
@flo-sch adding plain listener won’t help, the problem is that programmatic
form.submit()
does not fire event at all.