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

    lively-beach-14291

    10/03/2020, 4:55 PM
    I'd be nice if a TODO application showed this, perhaps by providing a count of the number of items.
  • g

    gorgeous-ghost-95789

    10/03/2020, 5:19 PM
    When you change a quantity the client, POST back to the server and load the new line back in to the browser. You should probably use an OOB swap to update the totals section at the bottom. Or, bonus points for pushing changes to specific spots using SSE.
  • m

    most-jelly-15242

    10/03/2020, 6:09 PM
    You can also trigger browser events from the server https://htmx.org/headers/x-hx-trigger/ and listen for the event to trigger another request to update the count. That's demoed here http://yoyo-app.beyondcritical.com/ in the 3rd example with the list + heart icons. When you click an item, that triggers an event from the browser and then the "Liked" count is updated below. These are 2 separate requests. Then when you click the "refresh" button, same thing happens (2 requests).
  • m

    most-jelly-15242

    10/03/2020, 6:12 PM
    You could also not have a 2nd request. Depending on how you implement it. When using hyperscript or Alpine, if you send the updated count together with the event, you could just read that and update the page. And OOB swaps allow you to do something similar.
  • m

    most-jelly-15242

    10/03/2020, 6:15 PM
    So, there's actually a bunch of ways to do it πŸ™‚
  • l

    lively-beach-14291

    10/03/2020, 7:31 PM
    Awesome. I discussed with a colleague today about something like server-side React; where I've got a server-side DOM for a user, and based upon events, a new DOM is made, the differences are computed, and then updated elements are pushed.
  • l

    lively-beach-14291

    10/03/2020, 7:36 PM
    Is it possible to have a single request provide a response that updates N distinct components?
  • l

    lively-beach-14291

    10/03/2020, 8:16 PM
    @User With firefox 81, only the 1st heart click works.
  • m

    most-jelly-15242

    10/03/2020, 8:59 PM
    > Is it possible to have a single request provide a response that updates N distinct components? @User If the server response includes the output for each component, then OOB swaps let you do this.
  • m

    most-jelly-15242

    10/03/2020, 9:02 PM
    > @User With firefox 81, only the 1st heart click works. @User I am using Firefox Developer Edition 82.0b6 and all 3 of them are working on my end. Weird.
  • l

    lively-beach-14291

    10/04/2020, 1:11 PM
    @User Google Chrome 85 on Ubuntu 20.04 also has this behavior, only 1st heart is counted.
  • m

    mysterious-toddler-20573

    10/04/2020, 2:14 PM
    > What about a syntax similar to the SSE connect: and swap:? That might be simpler to accomplish, and would be more consistent. @User yeah, I'm going back and forth on this
  • m

    mysterious-toddler-20573

    10/04/2020, 2:15 PM
    I like what I have, it's only 300 bytes in implementation so far so not awful
  • m

    mysterious-toddler-20573

    10/04/2020, 2:15 PM
    and it is more general, but is it too much?
  • m

    mysterious-toddler-20573

    10/04/2020, 2:15 PM
    πŸ€”
  • m

    mysterious-toddler-20573

    10/04/2020, 2:17 PM
    this also makes me think:
  • m

    mysterious-toddler-20573

    10/04/2020, 2:17 PM
    https://www.w3schools.com/css/css_attribute_selectors.asp
  • m

    most-jelly-15242

    10/04/2020, 2:54 PM
    @User Is there a reason for processing response headers right after a request, rather than after swap? https://github.com/bigskysoftware/htmx/blob/27d6fdd1e3e3d3cb3f11e8e2f97322ffd17ba129/dist/htmx.js#L1729 In the case of events if you want to do something with the swapped HTML as a result of the HX-Trigger, it doesn't look like it's possible at the moment.
  • g

    gorgeous-ghost-95789

    10/04/2020, 3:12 PM
    @mysterious-toddler-20573 - I was just throwing out another option, because it sounded like the lexer was giving you some trouble. But, 300 bytes sound pretty compact to me β€” I’ll be curious to see it when you’re settled.
  • g

    gorgeous-ghost-95789

    10/04/2020, 3:13 PM
    Will there be any chance to reuse the lexer in other parts of the library?
  • m

    mysterious-toddler-20573

    10/04/2020, 3:16 PM
    @User no reason other than that's when I did it in intercooler.js but I can see an argument for doing it after the swap...
  • m

    mysterious-toddler-20573

    10/04/2020, 3:18 PM
    @User yeah, i did the lexing a few different ways and finally struck on a clean way. I can adopt the lexer in the areas we do poor-mans parsing with split() right now and clean things up a bit. Still chewing on it.
  • g

    gorgeous-ghost-95789

    10/04/2020, 3:19 PM
    Nice!
  • m

    mysterious-toddler-20573

    10/04/2020, 3:19 PM
    @User what if we offered a few different headers:
    HX-Trigger
    ,
    HX-Trigger-After-Swap
    ,
    HX-Trigger-After-Settle
    etc.
  • m

    most-jelly-15242

    10/04/2020, 3:20 PM
    That would be perfect! Right now I am solving it using an eventQueue that I later read on afterSwap.
  • m

    mysterious-toddler-20573

    10/04/2020, 3:24 PM
    '> tfw you should be working on work but you are working on an obscure open source project instead
  • m

    most-jelly-15242

    10/04/2020, 3:26 PM
    I know the feeling, it's exactly what I am doing as well with this Yoyo thing
  • m

    most-jelly-15242

    10/04/2020, 3:29 PM
    So basically, this is all your fault πŸ˜‰
  • l

    lively-beach-14291

    10/04/2020, 3:47 PM
    @mysterious-toddler-20573 Well, I can't cheer you on enough. Data scientists really need ways to better interact with browser front-ends without having to become Javascript experts.
  • m

    mysterious-toddler-20573

    10/04/2020, 4:01 PM
    https://github.com/bigskysoftware/htmx/commit/6da50570bc3cba4c0da72e1931cc3d4f30da0a4b
1...495051...1146Latest