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

    mysterious-car-3675

    02/15/2023, 2:57 AM
    that way it updates the "shape" without losing the pointers to original dom. but i'm new here
  • m

    mysterious-car-3675

    02/15/2023, 3:40 AM
    if I send a
    HX-Location
    header is there any else I need to set? (Like a return that's not 200?) I have the response header set and the page does have htmx. If instead I put a boosted link on page that does work.
  • m

    mysterious-toddler-20573

    02/15/2023, 3:42 AM
    a 200 response w/ that should work
  • m

    mysterious-car-3675

    02/15/2023, 3:42 AM
    me grug make header me no why no boost me
  • m

    mysterious-toddler-20573

    02/15/2023, 3:43 AM
    https://github.com/bigskysoftware/htmx/blob/7ea35d03c6226aaf278b47d80170132bad9384f0/src/htmx.js#L3048
  • m

    mysterious-car-3675

    02/15/2023, 3:43 AM
    lemme try to breakpoint around there, thx
  • m

    mysterious-car-3675

    02/15/2023, 3:46 AM
    is there a CDN with sourcemaps or unminified?
  • m

    mysterious-car-3675

    02/15/2023, 3:47 AM
    it doesn't look like the
    function fr(s,l...
    is ever getting hit
  • m

    mysterious-car-3675

    02/15/2023, 3:49 AM
    What's interesting is that fr() isn't used anywhere else in the code
  • m

    mysterious-car-3675

    02/15/2023, 3:50 AM
    ah... so was sending down with the initial page, not in regards to a separate request
  • m

    mysterious-car-3675

    02/15/2023, 3:54 AM
    so just a on load event did it, got it. so it doesn't work if its clean page request. shouldn't onload check for response headers?
  • s

    sparse-psychiatrist-6723

    02/15/2023, 4:12 AM
    Hi. I am having a problem with an OOB swap. I am returning a response with an HTML fragment that targets a TBODY and another HTML fragment that is to be swapped OOB. When the response is handled, a part (not the entire) of the is actually being swapped into the normal TBODY target instead of the its designated OOB target. If I only send 1 of the fragments back in the response, they get placed where intended. Here is what it looks like:
    Copy code
    <!-- The Response contains both the fragment for normal replace and the oob swap fragment
         This will put part of the OOB into the normal target #table-body-->
    <tbody id="table-body">
      <tr>
        <td>First</td>
        <td>Second</td>
        <td>Third</td>
        <td>Fourth</td>
      </tr>
    </tbody>
    <div class="paging-container" hx-swap-oob="true" id="pagingcontainer">Strange Swap!</div>
    
    
    <!-- When you use just the OOB in the response it replaces the #pagingcontainer properly -->
    <div class="paging-container" hx-swap-oob="true" id="pagingcontainer">Strange Swap!</div>
    
    <!-- When you use just the normal swap fragment with no OOB fragment it replaces in the target fine -->
    <tbody id="table-body"><tr><td>First</td><td>Second</td><td>Third</td><td>Fourth</td></tr></tbody>
    Am I doing something wrong? Or might this be a bug/
  • o

    orange-umbrella-16693

    02/15/2023, 8:24 AM
    https://github.com/bigskysoftware/htmx/issues/1198 seems related
  • s

    some-airline-73512

    02/15/2023, 10:29 AM
    Is there a way to specify Select-Oob in response header?
  • r

    ripe-action-67367

    02/15/2023, 10:40 AM
    What's your use case? If the server knows, what should be oob swapped, it can just render it as oob elements
  • c

    clean-piano-67951

    02/15/2023, 12:31 PM
    Hey I am having an issue with HTMX. I am calling a HTML swap and getting a template from flask. before the template is called, the cookie on the page is changed to a specific value. I am then calling a JS function with htmx:afterSwap. Like so:
    Copy code
    document.addEventListener('htmx:afterSwap', function (event) {
            console.log("Running checkCookie() function")
    
            // Check if the "current" cookie has a value of "0"
            if (document.cookie.includes("current=0")) {
                // Add the "hidden" class to the button with id "prevBtn"
                document.getElementById("prevBtn").classList.add("hidden");
            }
            if (document.cookie.includes("max=1")) {
                // Add the "hidden" class to the button with id "prevBtn"
                document.getElementById("nextBtn").classList.add("hidden");
                document.getElementById("nextBtn").classList.remove("hidden");
            }
            else {
                // Remove the "hidden" class from the button with id "prevBtn"
                document.getElementById("prevBtn").classList.remove("hidden");
            }
        });
  • c

    clean-piano-67951

    02/15/2023, 12:32 PM
    Does afterSwap wait until it has successfully finished swapping? because the it is going to the else, and not detecting the correct value of the cookie
  • c

    clean-piano-67951

    02/15/2023, 12:32 PM
    Essentially, I am trying to hide the "previous" button in a multi step form when current step = 0
  • c

    clean-piano-67951

    02/15/2023, 12:36 PM
    Or if anyone can suggest a better way i'd be grateful!
  • c

    clean-piano-67951

    02/15/2023, 12:46 PM
    Ended up using a header instead of a cookie 🙂
  • m

    mysterious-toddler-20573

    02/15/2023, 1:56 PM
    tables are really hard to deal with when combined with oob swaps unfortunately
  • s

    sparse-psychiatrist-6723

    02/15/2023, 1:56 PM
    Yeah It looks like it could be related. I have been trying a bunch of different combinations to get a workaround to this use case. Need to replace the on a table with new content and swap OOB a . The closest I have gotten is: Here is the input field that starts the request:
    Copy code
    <input class="field-input filter-input" 
           hx-include="#sort-criteria" 
           hx-indicator="#filter-ind"
           hx-post="..."
           hx-select="#table-body"
           hx-select-oob="#pagingcontainer" 
           hx-swap="outerHTML swap:.4s" 
           hx-target="#table-body"
           hx-trigger="keyup changed delay:500ms, search" 
           id="filter-input" 
           name="filter" 
           placeholder="Type to filter results"
      type="search">
    And here is the response from the server:
    Copy code
    <div>
      <tbody id="table-body">
        <tr>
          <td>First</td>
          <td>Second</td>
          <td>Third</td>
          <td>Fourth</td>
        </tr>
      </tbody> 
      <div class="paging-container" 
           hx-swap-oob="true" 
           id="pagingcontainer">Strange Swap!</div>
    </div>
    This will result in the OOB division getting swapped in properly, but the tbody just disappears from the DOM. I had to wrap both elements in a to even get that OOB to work.
  • m

    mysterious-toddler-20573

    02/15/2023, 1:57 PM
    Can you trigger an event on the div instead?
  • m

    mysterious-toddler-20573

    02/15/2023, 1:57 PM
    and have it refresh in a separate request?
  • s

    sparse-psychiatrist-6723

    02/15/2023, 2:00 PM
    I will give that a try next. Thanks for the suggestion
  • s

    sparse-psychiatrist-6723

    02/15/2023, 2:01 PM
    The div has a paging element for the table. So it would need to go to the database again to calculate the results for the paging pages etc.
  • s

    sparse-psychiatrist-6723

    02/15/2023, 2:02 PM
    maybe I would be better off just bringing back everything wrapping the table and that paging component
  • m

    mysterious-toddler-20573

    02/15/2023, 2:16 PM
    expanding the target is always going to be the simplest solution
  • s

    sparse-psychiatrist-6723

    02/15/2023, 2:24 PM
    Right. Thanks for all your time and effort you put into this library. Really appreciate it
  • m

    mysterious-toddler-20573

    02/15/2023, 2:34 PM
    no problem at all 🙂
1...102010211022...1146Latest