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

    bumpy-pilot-80789

    09/04/2022, 7:55 PM
    right now I'm adding the trigger to the
    window
    , which is the
    html
    -tag, I think
  • b

    bumpy-pilot-80789

    09/04/2022, 7:56 PM
    in any case, I can see that a listener is properly attached, and the resulting callback is being called when I manually dispatch the event from the browser console
  • l

    late-king-98305

    09/04/2022, 7:57 PM
    (Sorry - I didn't catch that your name has changed. I was sitting here thinking "Why is no one helping Phil, but Bart shows up and gets all the attention?" LOL) You can send headers without bodies, IIRC, but targeting may not be your best bet there. One thing to note, though, is that htmx uses
    XMLHTTPRequest
    under the hood, which means that a) it's going to follow redirects before you ever get it back (not an issue here); and b) 4xx and 5xx responses are going to be interpreted as errors, which means they're going to follow a different code path. I would almost either return a body with a simple "yes" or "no"; return a separate (maybe custom) header that indicated success or failure; or use an
    HX-Trigger
    header in the response to show either your "yay!" or "boo..." modal. https://htmx.org/headers/hx-trigger/ (404 indicates that there is a problem with the request itself. In this case, I think the request (i.e., transport) works, so returning some sort of 2xx response is going to be appropriate in either case.)
  • l

    late-king-98305

    09/04/2022, 7:57 PM
    TL;DR - 404's don't trigger htmx the way you think they might. ๐Ÿ™‚
  • b

    bumpy-pilot-80789

    09/04/2022, 7:58 PM
    okay, got it
  • b

    bumpy-pilot-80789

    09/04/2022, 7:58 PM
    1/ who's Phil? ๐Ÿ™‚ 2/ I'm going for the HX-Trigger header now, but the event does not seem to get fired
  • l

    late-king-98305

    09/04/2022, 8:00 PM
    @quiet-hydrogen-55425 - which is who my original question was directed. ๐Ÿ™‚ I guess it wasn't a change in name, you two just showed up at about the same time.
  • l

    late-king-98305

    09/04/2022, 8:00 PM
    Does it get fired on success?
  • b

    bumpy-pilot-80789

    09/04/2022, 8:00 PM
    no, only when dispatched manually from the browser's console
  • l

    late-king-98305

    09/04/2022, 8:05 PM
    I know Ben was working with you - he's one of the gurus. ๐Ÿ™‚ I went to look up what I did, and when I found it - I remembered that I ended up going the custom header route. It may not apply to what you're trying to do here, but this link has an example of registering a handler that will check for the presence of headers on every request. This particular application uses these headers to either display messages to the user, or to hide a modal once a server-side action has been completed. https://github.com/bit-badger/myPrayerJournal/blob/main/src/MyPrayerJournal/wwwroot/script/mpj.js#L85
  • b

    bumpy-pilot-80789

    09/04/2022, 8:10 PM
    yes, indeed, @gorgeous-ghost-95789 put me on the right track: this was a CORS issue
  • b

    bumpy-pilot-80789

    09/04/2022, 8:10 PM
    backend and frontend were on different domains, and the HX-Trigger header was not exposed
  • g

    gorgeous-ghost-95789

    09/04/2022, 8:12 PM
    Well thank you ๐Ÿ™‚ But I prefer to think of @mysterious-toddler-20573 and @gorgeous-airport-54386 as the real rock stars, and I'm one of their most-enthusiastic roadies.
  • b

    bitter-manchester-50350

    09/05/2022, 12:41 AM
    @astonishing-ghost-81474 grazie
  • d

    dry-pharmacist-51808

    09/05/2022, 1:10 AM
    When rendering paginated, searchable tables - is it preferable to leave the table content as a separate http request, where the entire container, with page numbers etc, are rendered first, then each search item results in the table element being replaced? or should you attempt to load everything, including the initial table content on the first request
  • t

    tall-river-23601

    09/05/2022, 4:59 AM
    Is there any chance that our templating engine will be linked on your page? I know, It has just a few Github stars, but I think it might be interesting for people doing SSR with Python. The documentation for fragments is at the section below at #virtual-elements.
  • s

    stocky-dentist-80693

    09/05/2022, 8:45 AM
    I usually render everything (search field + results + pager) on first request, with the results and pager in a
    #results
    tag. Then I have the search field wired up with
    hx-select="#results" hx-target="#results" hx-get="{$current_url}"
    so the table + pager get updated. All from one route & template partial.
  • f

    fancy-elephant-10660

    09/05/2022, 8:50 AM
    anybody got this problem, its mystery for me when doing hx-swap-oob the html tags are stripped. test it will place -> test Without any html tags
  • f

    fancy-elephant-10660

    09/05/2022, 8:53 AM
    ah if I wrap it in a div it will show the html tags. Why not with a ?
  • f

    fancy-elephant-10660

    09/05/2022, 8:57 AM
    To be clear it keeps tripping any table html tag but not divs?
  • b

    blue-ghost-19146

    09/05/2022, 11:07 AM
    Yep, this issue is mentioned quite frequently. It seems tables are tricky for parsing: https://discord.com/channels/725789699527933952/725789747212976259/992055323798028488
  • l

    late-king-98305

    09/05/2022, 2:21 PM
    https://tenor.com/view/mando-way-this-is-the-way-mandalorian-star-wars-gif-18467370
  • c

    cold-actor-53931

    09/05/2022, 2:22 PM
    Hi everyone! Just became aware of HTMX a short time ago... Apart from the excellent docs, is there a youtube introduction, or any other material you can suggest to become familiar, just to get started?
  • b

    bland-coat-6833

    09/05/2022, 2:27 PM
    What's your backend? There are a fair few youtube videos on using HTMX with Django and there's a training course available if you use Flask. (all assuming you're using python)
  • c

    cold-actor-53931

    09/05/2022, 2:37 PM
    Hey friend from Enhance! Well, my backend could be anything, I come from Java and RoR (early 90s to 2004), Drupal (2006-2015), WordPress (2012-2020), full stack MEAN or similar (2017-present?)... I'm highly intrigued by similarities between Enhance and HTMX (suggested by some Tweets somewhere...) and fascinated by a possible compatibility (with HTMX acting as the interactivity for Enhance) especially since reading about HTML as the consuming data form for Ajax queries.... so... suggestions? ๐Ÿ™‚
  • b

    bland-coat-6833

    09/05/2022, 3:02 PM
    Ha! Thought I recognised the pic! Iโ€™d probably have a browse at some of the Python videos on YouTube. Thereโ€™s been a few conference talks about using it with Django - theyโ€™ll probably be a good start to give you an overview and an idea of the concepts. Then maybe have a go with Enhance and dream of all the magical synergies that @mysterious-toddler-20573 and Brian will be creating.
  • c

    cold-actor-53931

    09/05/2022, 3:17 PM
    We're definitely on a roll with all this "new" (ha!) frameworks! Thanks, yes, have general knowledge of Python and that sounds like a good suggestion. Meanwhile, I am going gung ho with Enhance (which I see as a kind of server side html rendering that could fit right into HTMX) and while I can visualize pretty simply how Enhance and HTMX could fit (duh! HTML!), with Enhance fleshing out the multi-page app and more and HTMX bringing on the interactivity in declarative form, I am very excited to hear what that collaboration will bring, yes! Also came across this video:

    https://www.youtube.com/watch?v=u2rjnLJ1M98โ–พ

    is pretty cool as a short 18 min general vision ๐Ÿ™‚
  • g

    gorgeous-ghost-95789

    09/05/2022, 3:41 PM
    Iโ€™m currently just swapping out the whole table instead of trying to target individual rows. Gonna wait and see if it gets awful after 1000 rows, but Iโ€™m guessing it wonโ€™t be a noticeable difference.
  • b

    blue-ghost-19146

    09/05/2022, 4:01 PM
    Exactly what we do. On my local setup, I currently have 5000+ rows of data and there isnโ€™t much of a difference.
  • l

    little-state-82457

    09/05/2022, 7:42 PM
    Ok, I've been searching all over here and have seen folks with similar issues, but nothing seems to be working for me. I'm trying to dynamically update
    href
    and
    hx-get
    because I've got a couple of htmx-controlled items and pagination on the page and I'm trying to keep track of their state via querystrings. For example:
    ?tab=whatever&page=2
    . I've been trying something like this, which seems like it should work, but it's only ever paying attention to what's set on the
    hx-get
    when it first loads. The `href`s and the `hx-get`s update in the DOM and I get no errors. Help? ๐Ÿฅบ
    Copy code
    _="on updateRequest(string)
         set my @href to `?something&$string`
         then set my @hx-get to my @href
         then call htmx.process(me)"
1...817818819...1146Latest