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

    gorgeous-airport-54386

    08/05/2022, 10:04 AM
    you can check for htmx headers server side and serve a full page if none are present
  • s

    stocky-dentist-80693

    08/05/2022, 10:31 AM
    If you always want to respond with a full page, you can also use
    hx-select="#article_list"
    in combination with some different
    hx-target
    and
    hx-swap
    attributes.
  • l

    loud-action-20310

    08/05/2022, 10:32 AM
    hello, I have multiple artist follow buttons on one page. Thought it's possible to replace them all using class selector like this:
    hx-swap="outerHTML" hx-target=".artist_following_8852"
  • l

    loud-action-20310

    08/05/2022, 10:33 AM
    but this is replacing just the first div of that class on a given page
  • l

    loud-action-20310

    08/05/2022, 12:41 PM
    is it possible to replace multiple elements at once?
  • t

    tall-dinner-62086

    08/05/2022, 1:05 PM
    Is having oob swaps inside a swappable element a no-no?
  • t

    tall-dinner-62086

    08/05/2022, 1:06 PM
    i.e.
    hx-target="main" hx-selec="main"
    where
    <main>
    has an element with an
    hx-swap-oob
    attribute inside
  • t

    tall-dinner-62086

    08/05/2022, 1:07 PM
    It seems like it just makes the element disappear entirely from the DOM
  • m

    mysterious-toddler-20573

    08/05/2022, 1:07 PM
    https://github.com/bigskysoftware/htmx/blob/master/src/htmx.js#L761
  • t

    tall-dinner-62086

    08/05/2022, 1:10 PM
    I'll take it as a "yes"
  • t

    tall-dinner-62086

    08/05/2022, 1:12 PM
    I was trying to use the oob swap with
    hx-swap="none"
    to avoid swapping the whole element but I guess I'll just work around it
  • t

    tall-dinner-62086

    08/05/2022, 1:14 PM
    Not like that, no. You can either use oob swaps or swap the whole parent
  • l

    loud-action-20310

    08/05/2022, 1:37 PM
    still would be a cool feature if class selectors actually replaced all matched elements
  • g

    great-manchester-46916

    08/05/2022, 2:08 PM
    Hi, not so much an htmx thing probably but if you get a 302 to redirect to a login page when the hx-target is a modal-container, is there a way to break out that in htmx or does it have to be in the login page. It's in .net core Razor Pages
  • r

    ripe-action-67367

    08/05/2022, 3:20 PM
    So, if i'm reading your question correctly, you want to redirect you user to a login page, insead of loading it into the modal. This can be achieved in two steps. 1) Check for HX-Request header to distinguish htmx-requests from normal ones. 2) When you need to redirect your user to login page and the request is coming from htmx, use HX-Redirect response header with 200 status code. For normal requests keep using 302 redirections. You will have to modify authorization middleware probably
  • r

    ripe-action-67367

    08/05/2022, 3:23 PM
    alternatively, use HX-Retarget response header to redirect swapping to an entire page. If your modal is opened with JS, use HX-Trigger to trigger an event that will close the modal. This approach is a bit more complicated and will probably cause some trouble when dealing with redirects after login is completed
  • w

    witty-garage-37227

    08/05/2022, 6:30 PM
    @great-manchester-46916 I think you need HX-Refresh (https://htmx.org/reference/#response_headers)
  • m

    mysterious-toddler-20573

    08/05/2022, 9:25 PM
    https://twitter.com/brianleroux/status/1555649141530718208
  • t

    tall-dinner-62086

    08/05/2022, 9:27 PM
    Not really feasible. The incoming page can have a different number of elements of that class. or they may not be in the same order
  • h

    hundreds-camera-24900

    08/06/2022, 12:43 AM
    is there a way to get a hx-Redirect have an hx-indicator?
  • h

    hundreds-camera-24900

    08/06/2022, 12:43 AM
    I click a button -> loading state -> response comes back triggering redirect -> load state disappears while redirect happens
  • j

    jolly-kite-167

    08/06/2022, 1:46 AM
    my new server - https://discord.gg/family-main
  • b

    bumpy-library-86484

    08/06/2022, 10:30 AM
    am I using extended css right here?
    hx-trigger="click from:find #id-of-input-child-element"
    can't find an example in the docs or the pr
  • g

    gorgeous-airport-54386

    08/06/2022, 10:50 AM
    "lmao htmx requires a server roundtrip for every interaction" meanwhile discord shows a loading spinner for a right click menu
  • g

    gorgeous-airport-54386

    08/06/2022, 10:52 AM
    Copy code
    jsx
    function RightClickMenu({ options }) {
      return <Loader load={options.menuItems}>
        <Spinner />
      </Loader>
    }
    someone had to code that
  • m

    mysterious-toddler-20573

    08/06/2022, 2:33 PM
    lol
  • h

    hundreds-camera-24900

    08/06/2022, 2:39 PM
    I actually broke discord due to all the clientside stuff and had to hard delete my cache - I accidentally pasted like 3k lines of code into a syntax highlighted triple ` block and because they did all parsing client side just scrolling up a line took 30 seconds
  • h

    hundreds-camera-24900

    08/06/2022, 2:39 PM
    and then they "helpfully" cache your pending send so every time I came back to the room it was still there
  • g

    gorgeous-airport-54386

    08/06/2022, 3:43 PM
    one time i somehow managed to make Discord's CSS not load
  • g

    gorgeous-airport-54386

    08/06/2022, 3:43 PM
    On the Electron version
1...771772773...1146Latest