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

    mammoth-family-48524

    09/04/2022, 11:30 AM
    Yep
  • m

    mammoth-family-48524

    09/04/2022, 11:34 AM
    The docs (reference section) also make it sound like you can put a CSS selector in the hx-swap-oob attribute and it can match multiple DOM elements at once. I've only done the ID way so far.
  • m

    mammoth-family-48524

    09/04/2022, 11:37 AM
    Copy code
    html
    <div>I did not know you could do this formatting - thanks!</div>
    Three backticks followed by the word "html" for anyone else wondering 😁
  • m

    mammoth-family-48524

    09/04/2022, 11:38 AM
    I'm off for the day - good day/night!
  • a

    ancient-father-3063

    09/04/2022, 11:38 AM
    ah yeah, that was one of the first things I learned when coming to discord for help. It's really nice.
  • a

    ancient-father-3063

    09/04/2022, 11:39 AM
    you can also do three ticks and the name of the language like tickticktickhtml or tickticktickpy for python for highlighting and stuff
  • b

    bland-coat-6833

    09/04/2022, 1:52 PM
    I believe this won’t work as OOB elements have to be at the root of the returned html. I.e. they can’t be wrapped in another element.
  • b

    bland-coat-6833

    09/04/2022, 1:53 PM
    See the last paragraph here: https://htmx.org/docs/#oob_swaps
  • b

    bumpy-pilot-80789

    09/04/2022, 6:00 PM
    hi all! I'm new here and am wondering if I could use this channel to ask for some beginner's help?
  • g

    gorgeous-ghost-95789

    09/04/2022, 6:01 PM
    Welcome! You're probably in the right place. There's a mix of beginner/advanced discussion here. What's up?
  • b

    bumpy-pilot-80789

    09/04/2022, 6:01 PM
    well,I am implementing HTMX on a simple web page, which has a basic form with a classic submit button
  • b

    bumpy-pilot-80789

    09/04/2022, 6:02 PM
    I added an hx-post attribute to the and see the request successfully appear at some custom backend service I wrote
  • b

    bumpy-pilot-80789

    09/04/2022, 6:02 PM
    now, this service is returning http status code 204 (no content) and adds an HX-Trigger header field
  • b

    bumpy-pilot-80789

    09/04/2022, 6:02 PM
    however... the trigger doesn't seem to actually happen on the client's side
  • b

    bumpy-pilot-80789

    09/04/2022, 6:03 PM
    if I manually trigger the event on my browser's console, the desired effect takes place however
  • b

    bumpy-pilot-80789

    09/04/2022, 6:03 PM
    I added an event listener for the specific event to the with jQuery's .bind function
  • g

    gorgeous-ghost-95789

    09/04/2022, 6:03 PM
    One first thought -- HX-Trigger in the response header will trigger the event on the window (not on the DOM element that initiated the hx-post) so you need to look for it in the right place.
  • b

    bumpy-pilot-80789

    09/04/2022, 6:04 PM
    ok, so if I just add the event listener using
    addEventListener(...)
    that should work?let me try it right away
  • g

    gorgeous-ghost-95789

    09/04/2022, 6:05 PM
    Also, I'm not really familiar with jQuery, but I think that if you're using htmx + jQuery, you'll need to let jQuery know any time that htmx updates the DOM.
  • b

    bumpy-pilot-80789

    09/04/2022, 6:05 PM
    hm, that didn't do the trick
  • g

    gorgeous-ghost-95789

    09/04/2022, 6:05 PM
    Yeah,
    window.addEventListener()
    should work.
  • g

    gorgeous-ghost-95789

    09/04/2022, 6:05 PM
    shoot
  • b

    bumpy-pilot-80789

    09/04/2022, 6:05 PM
    ok, let me try that then
  • b

    bumpy-pilot-80789

    09/04/2022, 6:06 PM
    HTMX is not updatig the DOM as far as I know - the only use now is with this post trigger returning a 204
  • b

    bumpy-pilot-80789

    09/04/2022, 6:06 PM
    nope, still no triggering happening 😦
  • g

    gorgeous-ghost-95789

    09/04/2022, 6:07 PM
    Ok. What is the content that you're sending back in the HX-Trigger header? Is it possible that it's formatted incorrectly?
  • b

    bumpy-pilot-80789

    09/04/2022, 6:07 PM
    my browser's inspector tells me the event listener is there
  • b

    bumpy-pilot-80789

    09/04/2022, 6:07 PM
    perhaps, but it's just a simple string
  • b

    bumpy-pilot-80789

    09/04/2022, 6:07 PM
    HX-Trigger: form2mail
  • b

    bumpy-pilot-80789

    09/04/2022, 6:08 PM
    Copy code
    py
    response = make_response("", HTTPStatus.NO_CONTENT)
    response.headers["HX-Trigger"] = "form2mail"
    return response
1...814815816...1146Latest