You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The behaviour of websocket-extension with hx-on is a bit counter-intuitive in my opinion.
Connecting and receiving updates via the websocket works flawlessly, but registering events via hx-onon a child element of the hs-ext="ws"-element does not seem to work:
The events are received via global handler, though, so this works as expected:
<!-- end of body, working example -->
<script>
document.body.addEventListener('htmx:ws-connecting', function (evt) {
console.log(evt);
})
</script>
And registering on the ws element directly seems to work for consecutive connects, but not on the inital page laod:
<!-- this work on reconnects -->
<div hx-ext="ws" ws-connect="/ws/client" hx-on:htmx:ws-connecting="console.log('websocket connecting', event)">
event-holder
</div>
Is this a known issue? I haven't found any hints on such limitation in the docs (neither hx-on nor ws-ext).
The text was updated successfully, but these errors were encountered:
haja
changed the title
WebSockets: handling events with hx-on seems broken
[1.9.10] WebSockets: handling events with hx-on seems broken
Dec 31, 2023
Hi,
The behaviour of websocket-extension with
hx-on
is a bit counter-intuitive in my opinion.Connecting and receiving updates via the websocket works flawlessly, but registering events via
hx-on
on a child element of thehs-ext="ws"
-element does not seem to work:The events are received via global handler, though, so this works as expected:
And registering on the ws element directly seems to work for consecutive connects, but not on the inital page laod:
Is this a known issue? I haven't found any hints on such limitation in the docs (neither
hx-on
norws-ext
).The text was updated successfully, but these errors were encountered: