https://htmx.org logo
Join Discord
Powered by
# htmx-general
  • o

    orange-umbrella-16693

    01/11/2023, 8:14 PM
    This looks just like the thing I needed, thank you!
  • o

    orange-umbrella-16693

    01/11/2023, 8:16 PM
    Why do you ask
  • b

    boundless-vase-80440

    01/11/2023, 8:26 PM
    cause chat is the new todo (I'm doing one as a PoC of htmx)
  • b

    boundless-vase-80440

    01/11/2023, 8:26 PM
    PoC => proof of concept (sorry for the enterprisey jargon)
  • o

    orange-umbrella-16693

    01/11/2023, 8:48 PM
    new todo as in?
  • b

    boundless-vase-80440

    01/11/2023, 8:48 PM
    as in everyone does a todo app 🙂 now everyone does a chat app
  • b

    boundless-vase-80440

    01/11/2023, 8:49 PM
    as in "orange is the new black"
  • o

    orange-umbrella-16693

    01/11/2023, 9:22 PM
    Second question, is there a way to add event listeners to the WebSocket object used by it?
  • b

    boundless-vase-80440

    01/11/2023, 10:10 PM
    I don't know. Can't see anything like that in the docs... I think the idea is to send HTML and let HTMX do its swap magic.
  • o

    orange-umbrella-16693

    01/11/2023, 10:11 PM
    Yeah, I just want some special behavior through javascript on websocket close, like show a popup about it or something
  • o

    orange-umbrella-16693

    01/11/2023, 10:12 PM
    Esp if it's an unexpected close
  • b

    boundless-vase-80440

    01/11/2023, 10:13 PM
    you can setup auto reconnect, but I don't think you can "react" (😱 ) to the close event
  • o

    orange-umbrella-16693

    01/11/2023, 10:14 PM
    Auto reconnect is automatically on from what I know
  • b

    boundless-vase-80440

    01/11/2023, 10:15 PM
    correct and you can override the default behavior
  • b

    boundless-vase-80440

    01/11/2023, 10:16 PM
    it might be a nice feature request
  • b

    boundless-vase-80440

    01/11/2023, 10:18 PM
    maybe emit an event when the connection closes socket.onclose = function (e) { // If Abnormal Closure/Service Restart/Try Again Later, then set a timer to reconnect after a pause. if ([1006, 1012, 1013].indexOf(e.code) >= 0) { var delay = getWebSocketReconnectDelay(retryCount); setTimeout(function() { ensureWebSocket(elt, retryCount+1); }, delay); } };
  • b

    boundless-vase-80440

    01/11/2023, 10:19 PM
    if this functions emits an event you could listen to it using hyperscript
  • b

    boundless-vase-80440

    01/11/2023, 10:20 PM
    "but I might be mistaken" -- Rev. Billy Gibbons
  • o

    orange-umbrella-16693

    01/11/2023, 10:20 PM
    htmx:wsError
    from the source for the WebSocket onerror event, should fire on abnormal closure
  • o

    orange-umbrella-16693

    01/11/2023, 10:33 PM
    Or maybe one could override
    htmx.createWebsocket
  • p

    prehistoric-garden-45720

    01/12/2023, 4:15 AM
    https://github.com/bigskysoftware/htmx/issues/1198 opened.
  • b

    bumpy-kangaroo-60192

    01/12/2023, 5:00 AM
    Why is it that all the stuff I want to do is explicitly forbidden by every standards body and society on the planet, yet the javascript clowns can write the most incomprehensible and pointless things and every browser will support it
  • b

    bumpy-kangaroo-60192

    01/12/2023, 5:02 AM
    I am merely trying to do a 302 response based on information in my custom http header
  • b

    bumpy-kangaroo-60192

    01/12/2023, 5:06 AM
    I guess I should just befowl my logical urls and return a 200 👍! {redirect: "...."} json
  • o

    orange-umbrella-16693

    01/12/2023, 9:24 AM
    For the following content:
    Copy code
    html
    <div id="test">
      <p>Test AFTER swap</p>
    </div>
    
    <tr id="tr-test" hx-swap-oob="true">
      <td>Joe Smith</td>
      <td>joe@smith.com</td>
    </tr>
    function makeFragment(resp)
    with
    htmx.config.useTemplateFragments = true
    returns:
    DocumentFragment [ div#test, #text ]
    , missing the element I don't think this is the expected behavior?
  • b

    boundless-vase-80440

    01/12/2023, 10:15 AM
    grugs, what's the canonical way to include a custom request header in an HTMX call?
  • b

    boundless-vase-80440

    01/12/2023, 10:16 AM
    use case: I need to send a GET request with a. person's SSN as a header instead of as part of the path
  • o

    orange-umbrella-16693

    01/12/2023, 10:18 AM
    hx-headers
    seems to fit the bill? https://htmx.org/attributes/hx-headers/
  • o

    orange-umbrella-16693

    01/12/2023, 10:18 AM
    With the
    javascript:
    prefix
  • b

    boundless-vase-80440

    01/12/2023, 10:20 AM
    🤦‍♂️
1...979980981...1146Latest