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

    mysterious-toddler-20573

    02/12/2023, 3:03 AM
    how could body be null?
  • b

    brief-flower-84254

    02/12/2023, 3:03 AM
    No idea 🙂
  • m

    mysterious-toddler-20573

    02/12/2023, 3:03 AM
    me neither
  • b

    brief-flower-84254

    02/12/2023, 3:06 AM
    huh, if I put hx-history-elt on the main div, it seems to work
  • b

    brief-flower-84254

    02/12/2023, 3:07 AM
    Omitting it def makes it blow up. Interesting.
  • b

    brief-flower-84254

    02/12/2023, 3:12 AM
    If I have time tomorrow I’ll try and put a simple repro together.
  • m

    mysterious-toddler-20573

    02/12/2023, 3:13 AM
    roger roger
  • b

    best-fireman-79576

    02/12/2023, 7:50 AM
    Does this combobox demo work for anyone? It doesn't seem to work for me (Firefox on Fedora) https://benpate.github.io/hyperscript-widgets/combobox/
  • t

    tall-dinner-62086

    02/12/2023, 11:24 AM
    Nope, getting a whole bunch of CSP errors
  • b

    brief-flower-84254

    02/12/2023, 4:39 PM
    Ha, I figured it out. For some reason htmx and browser-sync don't play nice together
  • b

    best-fireman-79576

    02/13/2023, 3:16 AM
    Are components a thing? Is there a guide on how to get some form of reusability?
  • b

    bumpy-kangaroo-60192

    02/13/2023, 4:17 AM
    https://htmx.org/essays/template-fragments/
  • h

    happy-knife-63802

    02/13/2023, 9:54 AM
    ive come across a situation where im swapping in a new fragment oob but none of the hx triggers are firing on the swapped in content.. console doesnt show any action and no requests are being made - any ideas?
  • h

    happy-knife-63802

    02/13/2023, 9:55 AM
    it works fine on a full page refresh when the updated fragment is loaded inline
  • h

    happy-knife-63802

    02/13/2023, 10:13 AM
    solved, swapped in fragment didnt reference the url properly. user error strikes again
  • m

    microscopic-art-61410

    02/13/2023, 4:05 PM
    is there a way to swap in just attributes from a hx-swap-oob, eg. add a class to an existing element?
  • m

    mysterious-toddler-20573

    02/13/2023, 4:09 PM
    not currently, although the morph extension does this to an extent
  • f

    famous-iron-45600

    02/13/2023, 5:32 PM
    I'm using
    hx-history="false"
    directive on one of my elements and when I click browser back it retrieves page elements from the server and not from the
    htmx-history-cache
    . I've also noticed that when htmx loads history from the server it adds the header
    HX-History-Restore-Request
    around which I've built a custom logic that adds a response header
    HX-Location
    but this response is not handled by the htmx. I've taken some time and did some research on htmx source code and I found that
    loadHistoryFromServer
    function doesn't check for response headers at all. I can understand why, but still wonder if was there any particular reason to handle
    XMLHttpRequest
    differently than
    handleAjaxResponse
    function for instance?
  • b

    busy-tomato-43957

    02/13/2023, 8:38 PM
    so apparently webkit is adding support for "declarative shadow dom", https://webkit.org/blog/13851/declarative-shadow-dom/ which lets you use shadow dom without js. ( https://webkit.org/blog/4096/introducing-shadow-dom-api/ ) I'm honestly very familiar with these features, but it seems like there could be some interesting overlap with htmx... thoughts?
  • b

    brainy-grass-55742

    02/13/2023, 9:08 PM
    Copy code
    html
    <button hx-post="/endpoint" id="myid1" hx-target="#result-div1" type="button">
    <button hx-post="/endpoint" id="myid2" hx-target="#result-div2" type="button">
    Is there a way to get the value of the id that triggered an HTMX event?
  • b

    busy-tomato-43957

    02/13/2023, 9:14 PM
    Probably the simplest way is to add a query parameter to distinguish them on the backend:
    Copy code
    <button hx-post="/endpoint?id=myid1" id="myid1" hx-target="#result-div1" type="button">
    <button hx-post="/endpoint?id=myid2" id="myid2" hx-target="#result-div2" type="button">
    But maybe you don't want that solution and you have a good reason for making things more complicated, in that case there also hx-include https://htmx.org/attributes/hx-include/
  • b

    brainy-grass-55742

    02/13/2023, 9:20 PM
    Going with the first option, how may I access the id in
    htmx:responseError
    event?
  • m

    mysterious-toddler-20573

    02/13/2023, 9:20 PM
    htmx will include the ID of the triggered element in the
    HX-Trigger
    request header (not to be confused w/ the
    HX-Trigger
    response header, which triggers an event)
  • b

    brainy-grass-55742

    02/13/2023, 9:23 PM
    can I access this value in
    htmx:responseError
    ? My
    evt.detail.triggeringEvent
    doesnt show this value
  • m

    mysterious-toddler-20573

    02/13/2023, 9:27 PM
    oh, I thought you wanted this server side
  • m

    mysterious-toddler-20573

    02/13/2023, 9:27 PM
    lemme look at the code, one sec
  • m

    mysterious-toddler-20573

    02/13/2023, 9:28 PM
    looks like you do have the target
  • m

    mysterious-toddler-20573

    02/13/2023, 9:28 PM
    is that enough?
  • b

    brainy-grass-55742

    02/13/2023, 9:29 PM
    evt.target.id
  • e

    echoing-dress-67727

    02/13/2023, 9:31 PM
    @mysterious-toddler-20573 not sure if you saw my ping the other day or my PR, but I wanted to make sure it's on your radar: https://github.com/bigskysoftware/htmx/pull/1250
1...101810191020...1146Latest