You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to submit SUI form via javascript?
I tried pretty much everything I could but the form is not launching the onSubmit.
The only thing that works is to find the submit button and click() on it.
I tried
<Form name="myForm" .... />
and
document.myForm.submit();
But this does not trigger the onSubmit behaviour.
WHY I need it? I have very large forms and I have keyboard shortcuts that allow to save the form.
The text was updated successfully, but these errors were encountered:
tomitrescak
changed the title
Submit Form
Submit Form with javascript does not trigger onSubmit
Nov 11, 2016
I've never tried submitting React forms like that, but apparently, React does not call onSubmit when you try to submit the form through the DOM. This makes some sense, as you are trying to invoke a virtual DOM method (onSubmit) using the real DOM form and API. I am betting this doesn't work because the real DOM is only the output of the component, not the actual component itself. Here is a vanilla React example that shows React simply does not support this:
I think the more "React way" of doing this would be to use controlled form controls that hoist their values into the component state or app state using their onChange listener. Then, your onSubmit handler just uses the data from state to do what it needs to do. Finally, you can invoke what ever function you passed to onSubmit directly and achieve the same results as a submission.
Is it possible to submit SUI form via javascript?
I tried pretty much everything I could but the form is not launching the onSubmit.
The only thing that works is to find the submit button and click() on it.
I tried
But this does not trigger the onSubmit behaviour.
WHY I need it? I have very large forms and I have keyboard shortcuts that allow to save the form.
The text was updated successfully, but these errors were encountered: