https://htmx.org logo
Join Discord
Powered by
# htmx-general
  • https://htmx.org/attributes/hx-select-oob/ It is not clear from this example (or the documentation) that the format of `hx-select-oob` needs to be a comma separated list of ids without `#` and without spaces. On my machine, `hx-select-oob="#id_one, #id_two"` fails, as does `hx-select-oob="id_one, id_two"`; the correct format seems to be `hx-select-oob="id_one,id_two"` Personally, I feel like it should accept the first option (`#` + spaces), since that's most in line with `hx-select`. Should I open a GH issue for this?
    w

    white-motorcycle-95262

    04/05/2023, 3:20 PM
    https://htmx.org/attributes/hx-select-oob/ It is not clear from this example (or the documentation) that the format of
    hx-select-oob
    needs to be a comma separated list of ids without
    #
    and without spaces. On my machine,
    hx-select-oob="#id_one, #id_two"
    fails, as does `hx-select-oob="id_one, id_two"`; the correct format seems to be
    hx-select-oob="id_one,id_two"
    Personally, I feel like it should accept the first option (
    #
    + spaces), since that's most in line with
    hx-select
    . Should I open a GH issue for this?
  • that seems like a bug
    m

    mysterious-toddler-20573

    04/05/2023, 4:39 PM
    that seems like a bug
  • I also want to support a leading `<` and trailing `/>` to keep syntax similar to htmx
    m

    mysterious-toddler-20573

    04/05/2023, 4:39 PM
    I also want to support a leading
    <
    and trailing
    />
    to keep syntax similar to htmx
  • Hello everyone! I'm a beginner with htmx trying to play around, and I have a question regarding triggering events with the HX-Trigger response header, custom data associated with the event, and using hx-trigger"mycustomevent from:body" on an element: Is it possible to be able to access the custom data from the event within the request that subsequently gets triggered? Or if I use the hx-trigger attribute i'm forced to ignore the custom data?
    b

    bulky-monitor-77900

    04/05/2023, 4:44 PM
    Hello everyone! I'm a beginner with htmx trying to play around, and I have a question regarding triggering events with the HX-Trigger response header, custom data associated with the event, and using hx-trigger"mycustomevent from:body" on an element: Is it possible to be able to access the custom data from the event within the request that subsequently gets triggered? Or if I use the hx-trigger attribute i'm forced to ignore the custom data?
  • what are you trying to do with the data?
    m

    mysterious-toddler-20573

    04/05/2023, 4:46 PM
    what are you trying to do with the data?
  • You can access it for filtering purposes, but if you are doing anything more elaborate you should use an event handler of some flavor (vanillajs, alpine, hyperscript, etc.)
    m

    mysterious-toddler-20573

    04/05/2023, 4:47 PM
    You can access it for filtering purposes, but if you are doing anything more elaborate you should use an event handler of some flavor (vanillajs, alpine, hyperscript, etc.)
  • yeah, it was for filtering
    b

    bulky-monitor-77900

    04/05/2023, 4:48 PM
    yeah, it was for filtering
  • ideally, using it as a query parameter or including it in the request somewhere for the triggered element
    b

    bulky-monitor-77900

    04/05/2023, 4:51 PM
    ideally, using it as a query parameter or including it in the request somewhere for the triggered element
  • if you are filtering, you can use an event filter and refer to the argument by name: ```html <div hx-trigger="my-custom-event[someProp == true]" ... ```
    m

    mysterious-toddler-20573

    04/05/2023, 4:52 PM
    if you are filtering, you can use an event filter and refer to the argument by name:
    Copy code
    html
      <div hx-trigger="my-custom-event[someProp == true]"
           ...
  • if you want to pass the information on in the request, you'll need to write a custom event handler
    m

    mysterious-toddler-20573

    04/05/2023, 4:52 PM
    if you want to pass the information on in the request, you'll need to write a custom event handler
  • ah, I see
    b

    bulky-monitor-77900

    04/05/2023, 4:53 PM
    ah, I see
  • but I wouldn't be able to do something like change the hx-get url to include a parameter based on the event, or even have different urls on the element based on the event... looks like a custom event handler is the way to go
    b

    bulky-monitor-77900

    04/05/2023, 4:55 PM
    but I wouldn't be able to do something like change the hx-get url to include a parameter based on the event, or even have different urls on the element based on the event... looks like a custom event handler is the way to go
  • is it possible to use hyperscript to adjust the url that the hx-get uses on the triggering event?
    b

    bulky-monitor-77900

    04/05/2023, 4:56 PM
    is it possible to use hyperscript to adjust the url that the hx-get uses on the triggering event?
  • One sec, lemme look
    m

    mysterious-toddler-20573

    04/05/2023, 5:02 PM
    One sec, lemme look
  • Yeah, OK
    m

    mysterious-toddler-20573

    04/05/2023, 5:02 PM
    Yeah, OK
  • so, if you catch the `htmx:configRequest` there will be a detail field, `evt.detail.triggeringEvent` that should hold the event that triggers the request in it. You can get the `detail` for _that_ event and then update the url in the configRequest event something like this: ```js htmx.on("htmx:configRequest", function(evt) { if(evt.detail.triggeringEvent.type === "myCustomEvent"){ evt.detail.url = evt.detail.triggeringEvent.detail.someCustomField; } }); ```
    m

    mysterious-toddler-20573

    04/05/2023, 5:07 PM
    so, if you catch the
    htmx:configRequest
    there will be a detail field,
    evt.detail.triggeringEvent
    that should hold the event that triggers the request in it. You can get the
    detail
    for that event and then update the url in the configRequest event something like this:
    Copy code
    js
      htmx.on("htmx:configRequest", function(evt) {
        if(evt.detail.triggeringEvent.type === "myCustomEvent"){
            evt.detail.url = evt.detail.triggeringEvent.detail.someCustomField; 
        }
      });
  • a little confusing, since there are two events, the `configRequest` event and the triggering event, but that will let you pass some context through to the request
    m

    mysterious-toddler-20573

    04/05/2023, 5:08 PM
    a little confusing, since there are two events, the
    configRequest
    event and the triggering event, but that will let you pass some context through to the request
  • that's cool though, I'll give it a shot!
    b

    bulky-monitor-77900

    04/05/2023, 5:28 PM
    that's cool though, I'll give it a shot!
  • thanks!
    b

    bulky-monitor-77900

    04/05/2023, 5:28 PM
    thanks!
  • How one would approach building a large table? 5000 rows for example, it is sluggish and requires some sort of lazy rendering/row virtualization
    s

    some-airline-73512

    04/05/2023, 8:44 PM
    How one would approach building a large table? 5000 rows for example, it is sluggish and requires some sort of lazy rendering/row virtualization
  • 5000 rows in what context?
    m

    mysterious-toddler-20573

    04/05/2023, 8:54 PM
    5000 rows in what context?
  • Just 5000 <tr> elements in a <table>
    s

    some-airline-73512

    04/05/2023, 8:56 PM
    Just 5000 elements in a
  • Are you swapping them in one by one? Or just slamming a big table in?
    m

    mysterious-toddler-20573

    04/05/2023, 8:56 PM
    Are you swapping them in one by one? Or just slamming a big table in?
  • Not even mentioning any scripting, just plain html is slow when there are so many rows
    s

    some-airline-73512

    04/05/2023, 8:56 PM
    Not even mentioning any scripting, just plain html is slow when there are so many rows
  • 🙂 You may be pushing the browser a bit too hard, is paging an option?
    m

    mysterious-toddler-20573

    04/05/2023, 8:56 PM
    🙂 You may be pushing the browser a bit too hard, is paging an option?
  • No, paging not an option
    s

    some-airline-73512

    04/05/2023, 8:57 PM
    No, paging not an option
  • People usually use lazy rendering in this case. Just rendering a "visible window" of rows, when a user scrolls down, removing top rows and rendering bottom rows
    s

    some-airline-73512

    04/05/2023, 8:57 PM
    People usually use lazy rendering in this case. Just rendering a "visible window" of rows, when a user scrolls down, removing top rows and rendering bottom rows
  • ah, a dynamic table
    m

    mysterious-toddler-20573

    04/05/2023, 8:57 PM
    ah, a dynamic table
  • This way the actual rendered rows are just for visible portion
    s

    some-airline-73512

    04/05/2023, 8:58 PM
    This way the actual rendered rows are just for visible portion
  • Well, we have lazy load, but a fully dynamic scroll-both-ways table seems like it would need some careful event management
    m

    mysterious-toddler-20573

    04/05/2023, 8:58 PM
    Well, we have lazy load, but a fully dynamic scroll-both-ways table seems like it would need some careful event management
1...108610871088...1146Latest