htmx
htmx copied to clipboard
tx-trigger="every 1ms"
If I create a range slider like so
<input
type="range"
name="value"
hx-target="#range-value"
hx-post="/range"
hx-trigger="every 10ms"
>
I will see a POST every time the slider is moved (rate limited to 10ms), but not once every 10ms.
Also, I will also see a POST every second, even when the range value is not changing.
Is this expected behavior? What am I missing?
Many thanks—and HTMX rocks!
I think you are also looking for delay.
https://htmx.org/attributes/hx-trigger/
delay:
Thank you @cemrehancavdar for the fast response!
I think you are also looking for delay.
Yes, in a real-world situation, that would be helpful—in this particular case, I am looking for clarification on the noted behavior.
More specifically, I expect 100 requests per second to the endpoint mentioned in hx-post
, but instead I see requests at approximately that rate only while the value is changing (when I did not specify changed
in hx-trigger
).
Oddly, I also see one request every second, when the range control is not changing (with or without changed
).
I see clarification as to whether my understanding is incomplete and/or the behavior is unintended.
i wonder if the requests are "piling up" because htmx will, by default, only issue one request at a time and will keep one request queued. So the response time also figures in just how quickly the requests will be reissued.
sorry, accidentally closed
1cg wrote:
i wonder if the requests are "piling up" because htmx will, by default, only issue one request at a time and will keep one request queued. So the response time also figures in just how quickly the requests will be reissued.
Thanks for looking at this!
I don't think the above hypothesis is it, since
I see requests at approximately [the expected] rate [...] while the value is changing
In other words, the request rate is possible, but I don't understand the behavior (and think it's likely a bug).