How to use transition with form being summited from js #1320
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
The submit you are using To submit a remix import { useSubmit } from 'remix'
export default function Component(){
const submit = useSubmit()
return (
<Form method="post">
<Button
onClick={() => {
submit(solvingForm.current, {
method: 'post',
action: '/route-you-want-to-post'
})
}}
>
Da
</Button>;
</Form>
)
} Then you can access all the properties from |
Beta Was this translation helpful? Give feedback.
-
The simpler way is to put an ID to the Form and then add a form attribute to the button element with the ID of the form. That will tell the browser the form of that button is your other form and when you click it (if type is submit) it will submit the form. This way you don’t need to grab a ref or use the useSubmit hook, also it will work even without JS. |
Beta Was this translation helpful? Give feedback.
The simpler way is to put an ID to the Form and then add a form attribute to the button element with the ID of the form. That will tell the browser the form of that button is your other form and when you click it (if type is submit) it will submit the form.
This way you don’t need to grab a ref or use the useSubmit hook, also it will work even without JS.