mysterious-toddler-20573
10/28/2022, 2:48 AMmysterious-toddler-20573
10/28/2022, 2:49 AMmysterious-toddler-20573
10/28/2022, 2:49 AMbrainy-ice-92385
10/28/2022, 6:59 AMdelay
syntax, which debounces the given event by the given time.
<div
hx-trigger="input delay:500ms"
hx-swap="innerHTML"
hx-post="/api/setter"
hx-target="[data-save-indicator]"
hx-indicator="[data-save-indicator]"
_="on input tell the next <.htmx-indicator />
add .htmx-request to yourself
put 'Saving...' into yourself"
>
<label>
Write your input!
<input type="text" name="value" />
</label>
</div>
<div class="htmx-indicator" data-save-indicator>Saving...</div>
I wanted to use hx-indicator
but hx-indicator
adds the htmx-request
class to the given CSS selector when the request begins, after the delay. This is too late! I want to let users know their info is in safe hands as soon as possible.
So, I take things into my own hands with hyperscript to add the class myself immediately to show the indicator. This doesn't mess with htmx's use of that class at all.
I also reset the content of the indicator, since a prior API response could have changed it.boundless-vase-80440
10/28/2022, 10:57 AMprehistoric-wolf-75047
10/28/2022, 11:02 AMthrottle
doesn't seem to work for me. On an element like this <input type="number" hx-post="" hx-trigger="change throttle:10s">
the POST request ist sent immediately. Do I need to configure it differently?prehistoric-wolf-75047
10/28/2022, 11:34 AMthrottle
works. The request is expected to fire immediately but all subsequent requests within the declared time window are discarded.
Does anybody else find the wording in the docs unprecise?ripe-action-67367
10/28/2022, 12:15 PMprehistoric-wolf-75047
10/28/2022, 2:27 PMthrottle:<timing declaration>
- a throttle will occur before an event triggers a request. If the event is seen again before the delay completes it is ignored, the element will trigger at the end of the delay.
Both state that <timing>
introduces a delay before the request is fired and my observation is that the request is sent immediately.prehistoric-wolf-75047
10/28/2022, 2:32 PMClick…Request #1…1s…2s…Click (discarded)…3s…Click…Request #2
vs.
Click…1s…2s…Click (discarded)…3s…Request
The latter is how I understand how it should work. But maybe that's just because I'm not a native speaker.bitter-machine-55943
10/28/2022, 3:08 PMbitter-machine-55943
10/28/2022, 3:08 PMechoing-action-55459
10/28/2022, 3:48 PMechoing-action-55459
10/28/2022, 3:53 PMmysterious-toddler-20573
10/28/2022, 3:56 PMmysterious-toddler-20573
10/28/2022, 3:56 PMmysterious-toddler-20573
10/28/2022, 3:56 PMmysterious-toddler-20573
10/28/2022, 3:57 PMsilly-soccer-20915
10/28/2022, 4:10 PMmysterious-toddler-20573
10/28/2022, 4:18 PMsilly-soccer-20915
10/28/2022, 4:22 PMmysterious-toddler-20573
10/28/2022, 4:23 PMhx-preserve
attribute on it, and have it re-execute by placing an hx-head="re-eval"
on it.mysterious-toddler-20573
10/28/2022, 4:24 PMboosted
boolean in the detail for both pre-request and post-request events triggered by htmxechoing-action-55459
10/28/2022, 4:24 PMmysterious-toddler-20573
10/28/2022, 4:25 PMmysterious-toddler-20573
10/28/2022, 4:25 PMmysterious-toddler-20573
10/28/2022, 4:25 PMmysterious-toddler-20573
10/28/2022, 4:25 PMmysterious-toddler-20573
10/28/2022, 4:37 PMsilly-soccer-20915
10/28/2022, 4:41 PMjs
htmx.defineExtension('prevent-title-update', {
handleSwap: function(swapStyle, target, fragment, settleInfo){
settleInfo.title = document.title;
}
});