Sending alpine.js data via htmx hx-vals as a json
My goal is to be able to serialize alpine variables into JSON and send those JSONs to my backend via htmx. This would be way more convenient then sending disparate form input values and random hx-vals. Essentially I want to use an alpine.js object that I already have and pass it into htmx-vals. This seems like a very easy premise but is proving impossible to me thus far. Right now here's the code that I'm testing: <div id="test_div" x-data="{ testTest: [1,2,3] }"> <button hx-post="/test_handle" hx-ext="json-enc" hx-vals="js:{'data': JSON.stringify(testTest)}"> Submit </button> </div> Obviously
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.