-
-
Notifications
You must be signed in to change notification settings - Fork 32
-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a helper function to submit a form and call preventDefault on the event #79
Comments
I was actually speaking with @chiroptical and @gillchristian about this recently! You do need to capture the event and call Here's a tiny example of how that's done (though this example doesn't use Formless). First, the submission event is captured: Then, we call This prevents the browser from sending the handleAction = case _ of
HandleSubmit event -> do
H.liftEffect $ preventDefault event
F.handleAction handleAction handleEvent F.submit This is really tedious to do all the time, so I've explored adding a new helper function that calls |
@gillchristian and I are planning on working on this soon :) |
@thomashoneyman Thanks for the intricate answer! I tried adapting my code this way, by defining a new action type:
then adding the
and writing my handleAction handler:
However, now my action is executed twice. I think I might have something wrong with the recursive Edit: Ah damn. I needed to remove my |
I've renamed this to track adding a helper function, and we can keep it open for that purpose. @gillchristian and @chiroptical please feel free to link this issue when you get to that implementation! |
I'm pretty happy with formless so far! One thing is really strange and is bugging me though: I'm submitting my form using
F.submit
, which validates and then submits. However, my cypress tests fail, because cypress actually sees the form submit and the new URL that's being broadcast and navigates to that new URL, see here:This prevents my tests from passing, since a whole new page is loaded. Judging from this YouTube video from the cypress authors, to prevent this behavior, I'd have to call
event.preventDefault()
and then make my XHR request.Is there a way to do this (easily?) in formless?
The text was updated successfully, but these errors were encountered: