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

    ripe-action-67367

    12/05/2022, 8:18 AM
    the div is not an input element and contains no other input elements, therefore there is nothing to include.
    value
    is not a valid div attribute
  • a

    ancient-father-3063

    12/05/2022, 8:20 AM
    Ah thanks, so the problem I'm trying to solve is I just need to include something, any value so my backend can recognize it as coming from this page. Can you advise how to do that?
  • a

    ancient-father-3063

    12/05/2022, 8:21 AM
    I just want it to do something like, hx-include "xxx" so that in my backend I can say "if this get request has xxx do bla bla bla"
  • r

    ripe-action-67367

    12/05/2022, 8:23 AM
    probably, the simplest solution is hx-vals https://htmx.org/attributes/hx-vals you also said
    so my backend can recognize it as coming from this page
    , sounds awfully like
    HX-Current-URL
    header https://htmx.org/reference/#request_headers
  • m

    miniature-lizard-24702

    12/05/2022, 8:30 AM
    whats wrong with a query param?
  • m

    miniature-lizard-24702

    12/05/2022, 8:30 AM
    /mypage?from=x
  • m

    miniature-lizard-24702

    12/05/2022, 8:31 AM
    oh but if there is a HX-Current-URL that's better.
  • m

    miniature-lizard-24702

    12/05/2022, 8:31 AM
    oh nvm... you're submitting a form...
  • m

    miniature-lizard-24702

    12/05/2022, 8:31 AM
    😅
  • a

    ancient-father-3063

    12/05/2022, 8:41 AM
    Thanks, I don't think I can use hx-values because I can't modify this line of code directly, that's why I wanted it to include a value from a different div, because I can modify that div. But I think HX-Current-URL does sound exactly like what I'm looking for
  • a

    ancient-father-3063

    12/05/2022, 8:42 AM
    I can't find an example of how to format this exactly is it something like
    Copy code
    hx-headers="HX-Current-URL"
    or how to format this?
  • r

    ripe-action-67367

    12/05/2022, 8:44 AM
    you don't need to do anything on the front-end, this header should be already attrached
  • r

    ripe-action-67367

    12/05/2022, 8:46 AM
    you need to check request headers on the backend, extract the value of this header and implement your page detection logic
  • a

    ancient-father-3063

    12/05/2022, 8:53 AM
    ah yes, got it thanks!!!!
  • b

    boundless-queen-37046

    12/05/2022, 1:47 PM
    Hi! Is there an event that fires when all the scripts inside the HTML that was just swapped by HTMX have finished loading?
  • m

    mysterious-toddler-20573

    12/05/2022, 4:05 PM
    I'm not sure if the script tag eval is blocking, but I believe it is. If so, then
    htmx:afterSettle
    should run after all the script elements are evaluated: https://htmx.org/events/#htmx:afterSettle
  • h

    handsome-window-77114

    12/05/2022, 7:06 PM
    The 'HX-Trigger' header doesn't work with my backend server because (I guess) all the headers sent are lower case (so 'hx-trigger') and there is nothing I can do about that. HTTP headers should be case-insensitive. https://stackoverflow.com/questions/5258977/are-http-headers-case-sensitive
  • m

    mysterious-toddler-20573

    12/05/2022, 7:26 PM
    I can try to fix that for the next release, I believe we have a reg-ex that might be screwing things up
  • s

    some-airline-73512

    12/05/2022, 7:37 PM
    hx-select-oob doesn't support tbody? That's weird.
    Copy code
    html
    <div id="content">Content</div>
    <table>
        <thead>
            <tr>
                <td>Column</td>
            </tr>
        </thead>
        <tbody id="tbody">
            <tr>
                <td>1</td>
            </tr>
        </tbody>
    </table>
    <button hx-post="/ex/select-oob" hx-target="#content" hx-select="#content" hx-select-oob="#tbody">Click me</button>
    Ajax response:
    Copy code
    html
    <div id="content">Replaced</div>
    <tbody id="tbody">
        <tr>
            <td>2</td>
        </tr>
    </tbody>
    This replaces #content, but doesn't replace #tbody.
  • m

    mysterious-toddler-20573

    12/05/2022, 7:44 PM
    tables are a nightmare to deal with, especially w/ oob
  • m

    mysterious-toddler-20573

    12/05/2022, 7:45 PM
    if you are willing to give up IE compatibility, you can use the following setting to make things work:
    Copy code
    htmx.config.useTemplateFragments
  • m

    mysterious-toddler-20573

    12/05/2022, 7:45 PM
    set this to
    true
  • m

    mysterious-toddler-20573

    12/05/2022, 7:45 PM
    this will be the default in htmx 2, and we will never speak of tables again inshalla
  • s

    some-airline-73512

    12/05/2022, 7:47 PM
    @mysterious-toddler-20573 thank you so much
  • s

    some-airline-73512

    12/05/2022, 7:52 PM
    @mysterious-toddler-20573 actually it didn't help. I added it in meta tag:
    Copy code
    html
    <meta name="htmx-config" content='{"useTemplateFragments":true}'>
    This works:
    Copy code
    html
    <button hx-post="/ex/select-oob" hx-target="#tbody" hx-select-
    oob="#content">Click me</button>
    This doesn't:
    Copy code
    html
    <button hx-post="/ex/select-oob" hx-target="#content" hx-select="#content" hx-select-oob="#tbody">Click me</button>
  • s

    some-airline-73512

    12/05/2022, 7:53 PM
    Interestingly adding hx-select breaks it as well: This works:
    Copy code
    html
    <button hx-post="/ex/select-oob" hx-target="#tbody" hx-select-oob="#content">Click me</button>
    This doesn't:
    Copy code
    html
    <button hx-post="/ex/select-oob" hx-target="#tbody" hx-select="#tbody" hx-select-oob="#content">Click me</button>
  • h

    handsome-window-77114

    12/05/2022, 8:15 PM
    Thanks, that would be great!
  • h

    handsome-window-77114

    12/05/2022, 10:37 PM
    Sorry, your regex is correct. It's another issue: there is something in the web component I use which prevents event bubbling.
  • s

    some-airline-73512

    12/06/2022, 3:54 AM
    To anyone who may have similar problem. The order of tbody in response matters. If it's first element, then the swapping works. Mess...
  • m

    mysterious-toddler-20573

    12/06/2022, 4:38 AM
    tables really are a nightmare
1...933934935...1146Latest