Ahoy!
Just pushed an update that brings a major improvement to the `post()` function, along with a fix for a pesky issue in Trongate MX that a few of you might have bumped into.
WHAT PROBLEM HAS BEEN SOLVED
Trongate's `json()` function is useful when it comes to debugging. For example, it lets us inspect all posted form data effortlessly:
This gives you a clean, readable output of all the submitted variables - very handy when you’re building and testing forms.
Unfortunately, this wasn’t possible using Trongate’s `post()` function. Since `post()` was designed to retrieve individual fields only, there was no simple way to view *all* the data `post()` was handling behind the scenes - especially for JSON payloads, PUT and PATCH requests, or any other non-standard POST data.
THE SOLUTION
Now, the post() function has been improved and it's easy to get all of the variables that are available via post(). Finally, the following code works:
You can also get all request data with cleanup applied:
Of course, the original behaviour still works too:
IN SUMMARY
There's not really much to learn here. Quite simply, if you invoke post() without passing in any arguments, or by passing in an argument of true (bool) then the post function will return an array of all of the variables that are available via post(); This is super useful for debugging.
FIX FOR TRONGATE MX
In addition, I have sorted out an issue where combining `mx-animate-success` and `mx-after-swap` on the same element meant `mx-after-swap` wouldn’t trigger. They now work together properly, as they should.
This update keeps everything backwards compatible while making it much easier to debug your request data - especially for modern APIs and front-end tools that go beyond traditional form posts.
Enhanced post() function and MX Animation Fix
10 months ago
10 months ago
#1
10 months ago
#2
Well done DC! this will come in handy.