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

    stale-whale-50398

    08/23/2020, 12:18 AM
    Line 188-196 for Htmx
  • s

    stale-whale-50398

    08/23/2020, 12:20 AM
    Easier to read actual output
  • s

    stale-whale-50398

    08/23/2020, 12:23 AM
    Notice in the debugger window how there's not [event] tag next to the div, that's a visual representation of the event listener bound to the element.\
  • s

    stale-whale-50398

    08/23/2020, 12:23 AM
    Here's a working example from another page on a select element with htmx
  • m

    mysterious-toddler-20573

    08/23/2020, 2:45 AM
    @User is this dynamically created HTML?
  • m

    mysterious-toddler-20573

    08/23/2020, 2:45 AM
    Dynamic content that is added after the initial load will need to be processed manually
  • m

    mysterious-toddler-20573

    08/23/2020, 2:46 AM
    w/ the
    htmx.process
    method
  • s

    stale-whale-50398

    08/23/2020, 3:25 AM
    I don't see this mentioned anywhere in the docs, anywhere I can read more in it?
  • m

    mysterious-toddler-20573

    08/23/2020, 3:26 AM
    Sorry, I didn't document the javascript API :/
  • m

    mysterious-toddler-20573

    08/23/2020, 3:27 AM
    Basically you will need to call something like
    Copy code
    js
      htmx.process(htmx.find("#whatever"))
    after the table is created
  • m

    mysterious-toddler-20573

    08/23/2020, 3:27 AM
    where
    #whatever
    is a css selector that returns the element enclosing the table
  • m

    mysterious-toddler-20573

    08/23/2020, 3:28 AM
    htmx goes through the DOM and processes all the
    hx-
    attributes at load time, so if something comes in later (out of band, I sometimes call it) it has to be dealt with explicitly
  • s

    stale-whale-50398

    08/23/2020, 3:28 AM
    I was just looking in the code and saw it just takes element
  • m

    mysterious-toddler-20573

    08/23/2020, 3:29 AM
    It can get a little hairy if you have a lot of DOM manipulation going on out of band
  • m

    mysterious-toddler-20573

    08/23/2020, 3:55 PM
    code pen showing a minimal example of how CSS transitions can work in htmx with zero javascript: https://codepen.io/htmx/pen/poyRRQG
  • o

    orange-student-44532

    08/24/2020, 1:24 PM
    Intercooler.js and htmx being mentioned in this article which has been submitted to Hacker News: https://news.ycombinator.com/item?id=24258855
  • m

    most-jelly-15242

    08/24/2020, 3:38 PM
    Is it possible to do something like
    hx-target="parent"
    to replace the parent element without having to use a specific selector for the parent?
  • m

    most-jelly-15242

    08/24/2020, 3:42 PM
    Ok, I think I got it, using
    hx-target="this"
    on the parent seems to work.
  • m

    mysterious-toddler-20573

    08/24/2020, 4:45 PM
    yep, that works
  • m

    mysterious-toddler-20573

    08/24/2020, 4:46 PM
    you can also use "closest " where the selector is general
  • m

    most-jelly-15242

    08/24/2020, 5:28 PM
    Nice. I was searching the docs by somehow missed that. Quick question. I have a scenario where I have a button that changes state, like a favorite button, which can appear in two different places on the page, but with a different UI. One is button, the other an icon. When someone clicks either, I need to update the clicked element, but also trigger an update of the other element so it just refreshes, but doesn't toggle the state again. What would be the best approach for this?
  • m

    mysterious-toddler-20573

    08/24/2020, 5:53 PM
    Would an out of band update be reasonable?
  • m

    mysterious-toddler-20573

    08/24/2020, 5:53 PM
    https://htmx.org/docs#oob_swaps
  • m

    mysterious-toddler-20573

    08/24/2020, 5:54 PM
    I might target both elements w/ oob content so either one can submit to the same URL and still update both
  • m

    most-jelly-15242

    08/24/2020, 7:10 PM
    For my use case this would complicate things to much on the server side. I wouldn't mind triggering a secondary request on the other element, but I would need to be able to pass a variable "update" or control the request so it's /update instead of /toggle. I think something like that path-deps estension would be useful here except that it would need to support two different types of requests. One when the element is clicked directly (/toggle), and the other when the element is triggered through a custom event (/update). I will probably need to write some custom JS for this.
  • m

    most-jelly-15242

    08/24/2020, 7:11 PM
    Thanks!
  • m

    mysterious-toddler-20573

    08/24/2020, 7:23 PM
    Another option is a custom event triggered via the header
  • m

    most-jelly-15242

    08/24/2020, 7:43 PM
    Thanks, I am going to explore that route. I am guessing there's no way to automatically add custom vars using an event? For example, I use HX-Trigger to fire the event, and pass it some data that gets automatically included in the request?
  • m

    mysterious-toddler-20573

    08/24/2020, 7:45 PM
    the hx-trigger header should support arguments to the event
  • m

    mysterious-toddler-20573

    08/24/2020, 7:45 PM
    which will be passed on in details
1...171819...1146Latest