Closed kg-currenxie closed 1 year ago
Perhaps a little bit shorter:
<form hx-on::config-request="event.detail.parameters.sellAmount.replace(/,/g, '')">
Untested and written from a stupid mobile.
Thanks :) I see, I'll try that.. but I guess manipulating the event details is the "only" way to go?
Hmm, there are probably a few. But I can’t think of an easier HTMX way.
You may also create a function in JS that replicates the input text into a hidden field that is updated to reflect the value as Int.
As you seem to have a function to add punctuation anyway, this might be a cleaner approach.
In HTMX you would use hx-params with "not punctuated-field" to filter it out.
@kg-currenxie You could have your hx-vals
do the cleanup. Check this codepen
Basically:
hx-vals='js:{"side":"sell","amount":compileData()}
and define your compileData as
function compileData() {
return document.getElementById("sellAmount").value.replace(/,/g, '')
}
Oh, that’s also nice.
Ah the js:
trigger, smart :) I think that's good enough for us :) The hidden non-formatted input is good too :)
Couldn't make hx-on::config-request
work, but thank you both :)
Ah the
js:
trigger, smart :) I think that's good enough for us :)Couldn't make
hx-on::config-request
work, but thank you both :)
Are you using the latest HTMX? It was only recently added. But sure, you are welcome.
"htmx.org": "^1.9.3" 1.9.4 is from 9 days ago, was it that recent? :D
Update: Actually resolved to latest
"htmx.org": {
"version": "1.9.4",
"resolved": "https://registry.npmjs.org/htmx.org/-/htmx.org-1.9.4.tgz",
"integrity": "sha512-GB9afD20gYw708z2PjClwlDgNtD1p4RYQtlDKak/JyMhrgiSL8sPfGqdkNmSLrhuCFekWw9mLpRNK/+Xn9aayA=="
},
Yes! I think it’s a feature of the very, very recent version. 😄
Yes! I think it’s a feature of the very, very recent version. 😄
Indeed, at least this used syntax.
We have a case with inputs that are auto-formatted while you type
Which sends the comma in the request, which is not so nice:
The only way I found was this
Is there any way other way of manipulating form values, or is this it?
Input: