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

    refined-waiter-90422

    12/13/2022, 12:43 AM
    the whole partial thing is just to save some bandwidth lol
  • g

    gorgeous-ghost-95789

    12/13/2022, 12:43 AM
    Yeah, and rendering on the server, too.
  • g

    gorgeous-ghost-95789

    12/13/2022, 12:44 AM
    But different servers have different weirdnesses, and it's great that htmx has the tools to accommodate everyone.
  • r

    refined-waiter-90422

    12/13/2022, 12:45 AM
    Yup agreed, it's why htmx is my choice over hotwire, unpoly, etc. even though they are all great. The flexibility is unmatched.
  • r

    refined-waiter-90422

    12/13/2022, 12:56 AM
    Also being able to think of the full library entirely since its so small and in one file makes me feel like a jedi when doing htmx stuff.
  • j

    jolly-motorcycle-88169

    12/13/2022, 1:01 AM
    Is this the simplest way to send an elements innerHTML to the server in a post request?
  • j

    jolly-motorcycle-88169

    12/13/2022, 1:09 AM
    https://discord.com/channels/725789699527933952/725789747212976259/988581795828228116
  • j

    jolly-motorcycle-88169

    12/13/2022, 1:10 AM
    seems the link didnt work on its own
  • b

    bumpy-kangaroo-60192

    12/13/2022, 1:19 AM
    Is hx-select supposed to go in the document or in the responses?
  • b

    bumpy-kangaroo-60192

    12/13/2022, 1:21 AM
    Inheritance isn't working with hx-select the way I expected and it seems to be because the event source is also in the response and the ancestor is not.
  • r

    refined-waiter-90422

    12/13/2022, 1:27 AM
    Example- Before:
    <a href="/info">Info</a>
    After:
    <a href="#" hx-get="/info" hx-target="#page-content" hx-select="#page-content" hx-push-url="true">Info</a>
  • r

    refined-waiter-90422

    12/13/2022, 1:28 AM
    This will change the browser URL, and update the page in-place without a browser refresh.
  • r

    refined-waiter-90422

    12/13/2022, 1:30 AM
    But yeah you can set
    hx-select
    and
    hx-target
    to retrieve/swap any element you want.
  • r

    refined-waiter-90422

    12/13/2022, 1:30 AM
    From a full page, without making a partial.
  • r

    refined-waiter-90422

    12/13/2022, 1:31 AM
    Also you can remove
    hx-push-url="true"
    its just there for completeness for people who want to update the URL too.
  • r

    refined-waiter-90422

    12/13/2022, 1:34 AM
    So lets say you want to just update a widget on the page, using the exact same endpoint..
    Copy code
    html
    <a href="#" hx-get="/page" hx-select="#widget" hx-target="#widget">Update Widget</a>
  • r

    refined-waiter-90422

    12/13/2022, 1:35 AM
    no partials involved here
  • r

    refined-waiter-90422

    12/13/2022, 1:43 AM
    Honestly every middleware should add that disclaimer and example at the top of the readme.md šŸ˜›
  • w

    wonderful-school-81222

    12/13/2022, 2:13 AM
    Why is this an anti pattern?
  • w

    wonderful-school-81222

    12/13/2022, 2:14 AM
    For my case of deep linking where i use hex-push-url it seems almost required
  • o

    orange-umbrella-16693

    12/13/2022, 2:33 AM
    With the htmx ws extension is it possible to send using hx-send to a specific websocket instead of nearest? How is "nearest" websocket determined anyways?
  • a

    ancient-shoe-86801

    12/13/2022, 4:53 AM
    usually it's an indicator that the function is in charge of two different tasks (responsibilities) https://www.martinfowler.com/bliki/FlagArgument.html
  • w

    wonderful-school-81222

    12/13/2022, 5:38 AM
    I’m totally on board with this idea. But it still leaves me kinda lost on this notion of navigation and deep links. It kinda sounds like if I want to do SPA with HTMX I ought have to build extra controllers specifically designed to render full pages if I expect the user to want to deep link without the use of flags.
  • w

    wonderful-school-81222

    12/13/2022, 5:40 AM
    This is one area where React Router is super opinionated. But trades off lots of DevX along the way. Would love to see some best practices docs from HTMX on how to handle structuring pages/controllers for navigation.
  • r

    ripe-action-67367

    12/13/2022, 6:53 AM
    Nearest parent with ws-connect from the page tree. No, it is not possible atm
  • r

    ripe-action-67367

    12/13/2022, 6:54 AM
    You can work around that by triggering custom events, I think
  • e

    echoing-book-71490

    12/13/2022, 9:55 AM
    The way I'd think about it is same resources (urls) but different representations (different / partial template) based on HX-Request, HX-Current-URL, etc. headers. It's basically of the same problem as sending down different response types (e.g. HTML or JSON) based on the Accept header.
  • e

    echoing-book-71490

    12/13/2022, 10:00 AM
    There are a few ways to abstract matching headers for multiple representations for a single resource in MVC, but it doesn't seem like FastAPI (never used it, just googled) supports that natively very well. I found this discussion on HTML and JSON from a single url, maybe that could serve as inspiration: https://github.com/tiangolo/fastapi/issues/2140
  • s

    sticky-smartphone-28696

    12/13/2022, 11:17 AM
    I have an endpoint serving text/html from localhost:4000/example. I can visit in browser and see what I expect. I then create a simple htmx.html on localhost:80 where I include unpkg/htmx in a script tag in head, and a div with hx-get to the localhost:4000/example endpoint. Nothing happens. I have no CORS stuff going on on localhost:4000/example. It's as if htmx is not executing hx-get. I feel I'm missing something truly simple, as this is the simplest example I can come up with and it won't work. Any ideas?
  • s

    sticky-smartphone-28696

    12/13/2022, 11:19 AM
    Running htmx.logAll(); in Console returns "undefined" so it is indeed not loading.
1...946947948...1146Latest