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

    late-shampoo-89851

    01/10/2023, 4:15 PM
    Hey there, I actually think I found my answer. The user has a toggle (preview or create PDF) and depending on the state of said toggle I'll add or remove hx-disable.
  • l

    late-shampoo-89851

    01/10/2023, 4:15 PM
    Is that a sound solution?
  • m

    mysterious-toddler-20573

    01/10/2023, 4:27 PM
    it seems like a separate button for the two ops would be less complex
  • l

    late-shampoo-89851

    01/10/2023, 4:53 PM
    Could you elaborate this a bit? How could a button perform the normal method="POST" and the other the hx-post? This is something I haven't figured out. Btw. thanks for taking your time to answer my doubts!
  • m

    mysterious-toddler-20573

    01/10/2023, 5:09 PM
    something like:
    Copy code
    html
    <button hx-post="/pdf/preview" .../>
      Preview
    </button>
    <form target="/pdf">
      <button>Download PDF</button>
    </form>
    is what I'm getting at
  • m

    mysterious-toddler-20573

    01/10/2023, 5:09 PM
    split the two behaviors up
  • p

    prehistoric-garden-45720

    01/10/2023, 5:09 PM
    Sure @mysterious-toddler-20573. Here is a simplified response (all I did was simplify the content of the tables cells, and even with this simplification the OOB swap for that portion still doesn't fire):
    Copy code
    <div
      id="status"
      hx-get="/status?timeline_version=622"
      hx-trigger="every 2s"
      hx-swap="outerHTML"
    >
      <p class="time-smaller-font">
        Last timeline update:
        <span class="fw-bold">01-10 12:00</span> | Peer
        last seen:
        <span class="fw-bold">2 hours ago</span>
      </p>
    </div>
    
    <title id="titular" hx-swap-oob="true">Site Title</title>
    
      
    <tr
      id="message-2K8xTyJVBzMbJyCjEbuBrRSPJnv-card"
      hx-swap-oob="afterbegin:#message-cards-begin"
    >
      <td>Cell 1</td>
      <td>Cell 2</td>
    </tr>
    So the
    <div>
    swap works, as does the OOB swap for
    <title>
    . It's just the
    <tr>
    one that doesn't work. And this is the beginning of the portion to be replaced:
    Copy code
    <table class="table w-auto">
        
        <tbody id="message-cards-begin">
  • m

    mysterious-toddler-20573

    01/10/2023, 5:18 PM
    :/ I'm playing around w/ it and it looks like the oob/table/afterbegin combo isn't working properly, I'll need to dig into it
  • p

    prehistoric-garden-45720

    01/10/2023, 5:21 PM
    Thanks @mysterious-toddler-20573. Good to know I might not be completely crazy. šŸ™‚
  • a

    abundant-spring-38265

    01/10/2023, 5:25 PM
    is anyone using bootstrap toggle switch with HTMX and has an example how to post without having a submit button? 😮
  • l

    late-king-98305

    01/10/2023, 10:37 PM
    Assuming you're talking about https://getbootstrap.com/docs/5.2/forms/checks-radios/#switches - are you wanting it to submit when the user clicks it and it transitions the state to selected, or are you triggering the submission some other way, and just want the value server-side?
  • m

    mysterious-toddler-20573

    01/10/2023, 10:44 PM
    @hundreds-cartoon-20446 question for you on this LOC: https://github.com/bigskysoftware/htmx/blob/613f7b61d59e8ac4741e02d9f468ca635773ab2d/src/htmx.js#L1275
  • m

    mysterious-toddler-20573

    01/10/2023, 10:44 PM
    the "path" that is coming back (in Chrome, anyway) is the full URL, rather than just the path path
  • h

    hundreds-cartoon-20446

    01/10/2023, 10:56 PM
    That’s right yes, we need the full url in case the href is written as a relative link which could potentially conflict with another page with the same uri slug. The url goes through
    normalisePath()
    and becomes a root relative path before being used as the key for a history entry.
  • h

    hundreds-cartoon-20446

    01/10/2023, 11:00 PM
    Normalising the urls means the same url accessed like ā€œhttps://website.com/section/pageā€, ā€œ/section/pageā€ and ā€œpageā€ (when in /section) all are stored under the same key.
  • m

    mysterious-toddler-20573

    01/10/2023, 11:00 PM
    would you be opposed to normalizing it up front, so the path is a proper path in the requestConfig object?
  • h

    hundreds-cartoon-20446

    01/10/2023, 11:07 PM
    Not sure. There may be edge cases when a specific protocol or port is required for some urls, rather than inheriting from the requesting page.
  • h

    hundreds-cartoon-20446

    01/10/2023, 11:12 PM
    I was cautious to only normalise for writing and reading the history cache key, but it might be safe to use more widely.
  • h

    hundreds-cartoon-20446

    01/10/2023, 11:17 PM
    My guess is some of the tests might break, but it would be justified to adapt them if you plan to normalise all requests.
  • h

    hundreds-cartoon-20446

    01/10/2023, 11:24 PM
    Ah yes - this may be a reason not to: the #hash is not included in the normalised url (you definitely don’t want it in the history key because it changes the scroll position, which htmx manages separately), but it may be important for certain requests.
  • a

    abundant-spring-38265

    01/10/2023, 11:29 PM
    Yes, whe user clicks it so toggle on / toggle off:)
  • b

    busy-kangaroo-68336

    01/10/2023, 11:30 PM
    Hi! I'm trying to integrate htmx with tauri (that's like electron but with rust backend). The issue i have is that there is no talking http with tauri's backend from the javascript world. The communication is done via async functions. So I wonder if I could maybe intercept the htmx requests and provide the result myself ?
  • m

    mysterious-toddler-20573

    01/10/2023, 11:37 PM
    can you describe how the asycn functions work?
  • b

    busy-kangaroo-68336

    01/10/2023, 11:37 PM
    these are standard async javascript functions ...not sure what information you're after ...
  • b

    busy-kangaroo-68336

    01/10/2023, 11:38 PM
    these take parameters and return data in any form
  • m

    mysterious-toddler-20573

    01/10/2023, 11:39 PM
    is it like an RPC style call?
  • b

    busy-kangaroo-68336

    01/10/2023, 11:39 PM
    Copy code
    async function greet() {
      // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
      greetMsgEl.textContent = await invoke("greet", { name: greetInputEl.value });
    }
  • b

    busy-kangaroo-68336

    01/10/2023, 11:39 PM
    that's an example call
  • b

    busy-kangaroo-68336

    01/10/2023, 11:40 PM
    in my hypothetical scenario, i'm ready to implement some http lite if that's what's required
  • m

    mysterious-toddler-20573

    01/10/2023, 11:41 PM
    what's the
    invoke
    method doing? This is the RPC shim w/ a rust back end?
1...976977978...1146Latest