-
Hey everyone 👋 , I'm wondering about how htmx solves a specific race condition that I was previously avoiding using plain JS. It happens when one of our form elements triggers a request on change. The server responds with HTML, which is then replaced on the page. The race condition happens in this scenario:
The delay modifier doesn't solve this issue in theory because even if there is a delay of say 500ms between checkbox 1 and 2 being selected, it's still technically possible for request 2 to come back first. The way we were solving this via plain JS was to store the request time of the most recent request and ignore any updates that were < that request time. Does htmx offer anything like that solution? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The way to fix that is to hoist the request up the DOM to a parent element and then use a This will use a single request queue for all requests based on the parent element. |
Beta Was this translation helpful? Give feedback.
The way to fix that is to hoist the request up the DOM to a parent element and then use a
from: <CSS selector>
that matches both checkboxes.This will use a single request queue for all requests based on the parent element.