-
Notifications
You must be signed in to change notification settings - Fork 1
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
1.0.31 @submit trigger #2
Comments
Oh that's embarrassing. Please try again with new version 1.0.32 |
I'm not able to fully test right now but can you try new version 1.0.33 and see if that fixes it? |
Okay fingers crossed -- please try zjax@1.0.34 |
Is there any other info you can give me? It's working on my end and I don't really see any clues at all in that error. |
Error within call: |
Okay 1.0.35 fixes that bug. Note that your POST request won't contain any form data here since you're using the z-swap on an anchor tag instead of a form. |
also btw, you might find it useful to add this to the head section of of your document: <script>
zjax.debug = true;
</script> |
Yup, it's simple call POST with div, with form. |
Yeah, THAT bug fixed. |
In case anyone is interested, the issue is that submitting formData directly from JS fetch doesn't behave quite as expected. The actual FormData instance isn't stringified. The FormData object was apparently designed this way so that it can be flexible enough to also handle multipart (file uploads). But typically, a backend (I was testing with Node Express) is expecting the values to be a urlencoded string. By converting the formData to a string first, the payload arrives at the server as expected. Note that file uploads aren't yet supported but in the future, this will be supported by simply adding |
I'm not doing anything special at all with the formData. Here's how it currently works. First, we get instantiate the formData from the form element that triggered the z-swap: const formData = new FormData(event.target); Then we convert that to a string like this: function convertFormDataToString(formData) {
const urlEncodedData = new URLSearchParams();
for (const [key, value] of formData.entries()) {
urlEncodedData.append(key, value);
}
return urlEncodedData.toString();
} Do you see anything in there that should cause the issues you're seeing? |
I apologise, i don't understand anything about JavaScript and working inside a browser (and i don't like languages like JS in general). That's why I chose htmx for my work, and I've been using it for several years without writing a single line in JS (my main language is Go and SQL). Your library idea is even more interesting, so I tried it too. The essence of htmx is that a normal page, for example a form, which already works with the backend through normal queries, simply becomes interactive without changing anything on the backend. Your library can't just notice a normal form request at this point. Even worse is the case with DataStar, which I also considered, where it is necessary to completely redesign the backend, which is very difficult for me due to its size. So I can only point out the differences in working with a normal form, but will do nothing to help in understanding how JS works. Again, I apologise for that. :) |
Now all commands are broken:
z-swap="/test #offleft"
or
z-swap="@click /test #offleft"
it writes:
elements1.0.31 ZJAX ERROR – Unable to parse z-swap: @submit trigger is only available on
The text was updated successfully, but these errors were encountered: