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

    gorgeous-ghost-95789

    10/30/2020, 5:13 PM
    Not the same, but related -- I'm working on a real-time server that uses SSE to push changes to specific pages / page fragments when resources update on the back end. My use case definitely requires a server component that monitors assets, but the result is fantastic.
  • g

    gorgeous-ghost-95789

    10/30/2020, 5:16 PM
    From what @mysterious-toddler-20573 said, it seems like you could write an extension that listens for (and tracks) some sort of server version -- probably passed in the HTTP header. If this value changes, then your extension could trigger an event (named OMG_NEW_SERVER_VERSION) somewhere on your root DOM node. Then, your HTMX code could just listen for this event, something like
    <body hx-get="/the-app" hx-trigger="OMG_NEW_SERVER_VERSION">
    . I did something vaguely like this in an old Angular app, but building it on top of HTMX would be much cleaner.
  • g

    gorgeous-ghost-95789

    10/30/2020, 5:18 PM
    (in case it's not clear in my example, anything inside the tag would be swapped out by HTMX when that event fires. That should include any stylesheets that are contained within the body)
  • u

    user

    11/01/2020, 10:06 AM
    If I understand correctly: htmx has per definition (per concept) no template mechanism, meaning that all structural (declarative) information has to come from the server. Example: to fill a table with data from server, just a JSON list of entities is not enough, the list has to carry etc too?
  • m

    mysterious-toddler-20573

    11/01/2020, 1:15 PM
    Hi @User yes, htmx expects the HTTP transport to be HTML, rather than JSON. However, there is a client-side template extension if you wish to use JSON instead: https://htmx.org/extensions/client-side-templates/
  • u

    user

    11/01/2020, 1:18 PM
    ah this is helpful πŸ˜€
  • u

    user

    11/01/2020, 2:04 PM
    One point that I really like at htmx is got rethink web, its basic ideas and the principle of simplicity
  • g

    gorgeous-ghost-95789

    11/01/2020, 4:26 PM
    Exactly. Work with native elements (like DOM Nodes, HTTP, and Events) and fill in all of the connections between them that weren't already completed in the original browser specs.
  • m

    mysterious-toddler-20573

    11/01/2020, 5:49 PM
    yep! The goal of htmx is to complete HTML as a hypertext, so we can build nice UX within the original model of the web πŸ™‚
  • t

    thankful-alligator-83267

    11/02/2020, 7:43 AM
    Hi! I have a question about transitions. Is there some equivalent to unpoly's up-transition ="move-left"?
  • t

    thankful-alligator-83267

    11/02/2020, 7:43 AM
    I'd love to choose transitions in links
  • m

    mysterious-toddler-20573

    11/02/2020, 1:19 PM
    Hi Charles, no not out of the box. That would need to be accomplished with CSS animations in htmx.
  • m

    mysterious-toddler-20573

    11/02/2020, 1:26 PM
    and, actually on thinking on it, you'd need to write an exension for that :/
  • m

    mysterious-toddler-20573

    11/02/2020, 1:26 PM
    We don't keep both pieces of content in the DOM at the same time, which is what you would need
  • a

    ancient-soccer-8576

    11/02/2020, 5:24 PM
    > yep! The goal of htmx is to complete HTML as a hypertext, so we can build nice UX within the original model of the web πŸ™‚ @User one limit of this approach I think is that GUI code is distributed and not in a single place (compared for example with Alpine, vue, etc approach)... am i right?
  • g

    gorgeous-ghost-95789

    11/02/2020, 5:35 PM
    Meh? The Angular apps I built still spread code over a wide area. Think models, views, controllers, components... not to mention a duplicate of all that to generate JSON/REST endpoints.
  • g

    gorgeous-ghost-95789

    11/02/2020, 5:38 PM
    I don’t know that HTMX spreads code any more or less that other approaches. I do think it helps to move UI code into a more consistent place. HTML for structure, and JavaScript of client-side widgets (like that pesky calendar widget everyone rebuilds)
  • g

    gorgeous-ghost-95789

    11/02/2020, 5:38 PM
    What do you think, @ancient-soccer-8576?
  • u

    user

    11/02/2020, 5:45 PM
    Hi, I'am playing with htmx and loving it. Congrats! One question I wondering, what's the best practices for history/bookmarks. Imagine I select a resource in a list so I issue an hx-get /resource/123, I can push /resource/123 in the URL. If it's bookmarked, the /resource/123 is in fact only the HTML fragment. How do one works around this usually?
  • m

    mysterious-toddler-20573

    11/02/2020, 5:52 PM
    @User I typically will do a server side header check to see if it is an HTMX request or not, and if it is not I will render the entire page
  • m

    mysterious-toddler-20573

    11/02/2020, 5:52 PM
    using the standard application layout (this is in rails terms, ymmv)
  • u

    user

    11/02/2020, 5:53 PM
    Exactly what I was looking into right now, is HX-Current-URL is safe check?
  • m

    mysterious-toddler-20573

    11/02/2020, 5:53 PM
    @User The GUI code is in one place, in that it is all in HTML, but the glue code between the client and the server code is more split up, if I'm understanding you
  • m

    mysterious-toddler-20573

    11/02/2020, 5:55 PM
    @ancient-soccer-8576 I wrote an essay on Locality of Behavior: https://htmx.org/essays/locality-of-behaviour/
  • m

    mysterious-toddler-20573

    11/02/2020, 5:55 PM
    I think that htmx helps with that. However, if you are used to something that abstracts the serverside/clientside distinction away, then it is going to seem like the opposite
  • m

    mysterious-toddler-20573

    11/02/2020, 5:56 PM
    Something like livewire, or whatever, where you don't have (in theory) to worry about the distinction between the client side and server side
  • m

    mysterious-toddler-20573

    11/02/2020, 5:57 PM
    in htmx, you still do need to think in terms of HTTP requests and the more traditional stateless transformation model of the web
  • m

    mysterious-toddler-20573

    11/02/2020, 5:57 PM
    @User HX-Request will always be "true" for htmx requests see https://htmx.org/reference/#request_headers
  • a

    ancient-soccer-8576

    11/02/2020, 5:58 PM
    what i am struggling is for example if my http request will need to update more GUI objects placed in different places on the page...
  • m

    mysterious-toddler-20573

    11/02/2020, 5:58 PM
    Ah, yes. Classic problem with htmx
1...676869...1146Latest