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

    gorgeous-ghost-95789

    12/08/2020, 10:59 PM
    So, this means something like having separate discord channels for different things, or using separate areas of GitHub for bugs / feature discussions.
  • l

    lively-beach-14291

    12/09/2020, 1:19 AM
    So, github is now owned my Microsoft. Of all the big vendors, it's the nicest.
  • l

    lively-beach-14291

    12/09/2020, 1:23 AM
    https://fossil-scm.org has always been intriguing in this respect for me; in that it includes bugs in the repository
  • m

    mysterious-toddler-20573

    12/09/2020, 1:43 AM
    interesting
  • b

    big-airline-13935

    12/09/2020, 9:43 AM
    I didn't mean to throw anyone's plans off course, I guess I just think that there is benefit in having only one place to collect and discuss ideas. With properly assigned labels, Github issues can handle this quite well and it prevents fragmentation of ideas and the community in general.
  • m

    mysterious-toddler-20573

    12/09/2020, 1:52 PM
    I'll defer to you on this, I do like the idea of only having one place
  • b

    billions-rain-29850

    12/09/2020, 3:25 PM
    Dear Coommunity, I have a question about documentation and about _hyperscript. I have a working solution to combinate them:
    Copy code
    html
    <span data-script="on click add .d-none to .secondary then remove .d-none from #header" data-hx-post="/profil/addrow" data-hx-vars="input:'{{ @item.name }}'" data-hx-target="#sections" data-hx-swap="afterend"></span>
    Probably hyperscript runs independently this way - but runs. According to doc (https://htmx.org/docs/#hyperscript) I can use
    htmx:afterSettle
    event for hyperscript to run after htmx request is being completed. However it doesn't seem to be working for me. Do I miss something?
    Copy code
    html
    <!-- data-script won't trigger -->
    <span data-script="on htmx:afterSettle add .d-none to .secondary then remove .d-none from #header" data-hx-post="/profil/addrow" data-hx-vars="input:'{{ @item.name }}'" data-hx-target="#sections" data-hx-swap="afterend"></span>
    Thank you for your help! (These two libraries are awesome!) (Edit: discord markdown formatting things.)
  • m

    most-jelly-15242

    12/09/2020, 5:01 PM
    Just thinking out loud here. Maybe afterSettle doesn't trigger on the element, but only at the window/document level. If that's the case, you can't listen to it directly on the span.
  • m

    most-jelly-15242

    12/09/2020, 5:03 PM
    If that's the case, you could sent a HX-Trigger header server side with your response, then use that event https://htmx.org/headers/x-hx-trigger/
  • m

    mysterious-toddler-20573

    12/09/2020, 5:20 PM
    Yeah, this is a corner case, but the settle event is triggered on the content that was swapped in, rather than the content that triggered the request. So move that hyperscript up to the parent node and you should be good
  • m

    mysterious-toddler-20573

    12/09/2020, 5:21 PM
    Generally this is a problem I'm seeing a lot of: afterSettle when the content is swapped in elsewhere, what do
  • m

    mysterious-toddler-20573

    12/09/2020, 5:24 PM
    I wonder if we need another event, something like
    htmx:swapComplete
    that is triggered on the triggering element, and then handed to the body as well if the triggered element has been removed from the DOM. That seems like what most people want.
  • b

    billions-rain-29850

    12/09/2020, 5:29 PM
    @most-jelly-15242 Thank you, you were right! Adding
    Copy code
    php
    header('HX-Trigger: {"settle": true}');
    to my server-side controller and modifying template to
    Copy code
    html
    <span data-script="on settle add .d-none to .secondary then remove .d-none from #header" ...>
    did the trick. Maybe it's something that worth to mention in the docs. I will try @mysterious-toddler-20573 's method too.
  • m

    mysterious-toddler-20573

    12/09/2020, 5:31 PM
    @User yes, events sent from the server will be triggered on the elemen that caused the request.
    htmx:afterSettle
    is, instead, triggered on the content that was swapped in. So if the content is not within the element that triggered the request, that element will not see the event.
  • m

    mysterious-toddler-20573

    12/09/2020, 5:31 PM
    it's annoying, I need to add another event for what you are trying to do, this bites people frequently
  • m

    most-jelly-15242

    12/09/2020, 5:35 PM
    @User Another option would be to allow hyperscript to listen to events at the window level. AlpineJS has a
    window
    modifier for this. So for example
    on.window htmx:afterSettle
    or something like that.
  • b

    billions-rain-29850

    12/09/2020, 5:37 PM
    I see. Make sens. I wanted to show table after the table had some rows from a request. Request is based on an input, which can't be part of the table. Without settle trigger, there were two tiny DOM changes - now it's much smoother. So thank you for your help, both of you. (In action: Hungarian structural steel section table: https://structure.hu/profil)
  • m

    mysterious-toddler-20573

    12/09/2020, 5:52 PM
    @User yes, I have considered that as an option in hyperscript, something like:
    Copy code
    html
      <div _="on body.htmx:afterSettle ...">...</div>
  • m

    mysterious-toddler-20573

    12/09/2020, 5:53 PM
    awesome!
  • m

    mysterious-toddler-20573

    12/09/2020, 5:56 PM
    when I get back to hyperscript next year, I would love to hear about alpine use cases like this so I can think about how to integrate them into the language
  • m

    mysterious-toddler-20573

    12/09/2020, 5:56 PM
    very excited to get back into that, languages are my primary passion
  • m

    mysterious-toddler-20573

    12/09/2020, 5:57 PM
    very edifying to see hyperscript useful in the wild, despite being so early on 🙂
  • b

    billions-rain-29850

    12/09/2020, 6:04 PM
    I always like to see these small Dom modifications directly in templates rather than in separete js files and custom event listeners. I think its a good approach for serverside generated apps. Im a hobbist in webdev, I have time to play :)
  • m

    most-jelly-15242

    12/09/2020, 6:42 PM
    Another one https://twitter.com/MikeAbrahamsen/status/1336708816579121153?s=20 @mysterious-toddler-20573 sounds familiar? > Yet here I am, writing a whole lot of JavaScript so that I can write less JavaScript. I am an engineer, after all.
  • m

    mysterious-toddler-20573

    12/09/2020, 6:43 PM
    🙂
  • m

    mysterious-toddler-20573

    12/09/2020, 6:44 PM
    Yep, although it looks a bit more like stimulus
  • m

    mysterious-toddler-20573

    12/09/2020, 6:45 PM
    htmx is a bit different in that it focuses so much on enhancing HTML and leaves the server side stuff to higher level frameworks
  • m

    mysterious-toddler-20573

    12/09/2020, 6:45 PM
    but I'd be glad if he used htmx as a basis, like some other folks I know 😉
  • m

    mysterious-toddler-20573

    12/09/2020, 6:46 PM
    (I'm sure you know all this, I'm typing to hear myself think)
  • m

    mysterious-toddler-20573

    12/09/2020, 6:49 PM
    🙂 That's Locality of Behavior: https://htmx.org/essays/locality-of-behaviour/
1...899091...1146Latest