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

    hundreds-camera-24900

    06/28/2022, 2:35 AM
    what would it do - default to using nanomorph and attempt to keep current state of the dom?
  • h

    hundreds-camera-24900

    06/28/2022, 2:35 AM
    or blow away things that are different but keep global state?
  • h

    hundreds-camera-24900

    06/28/2022, 2:37 AM
    or just more generally - what's the most intuitive behavior for a generic swap?
  • m

    mysterious-toddler-20573

    06/28/2022, 2:47 AM
    All excellent questions answers for which we look forward to!
  • h

    hundreds-camera-24900

    06/28/2022, 3:13 AM
    o7
  • a

    ancient-father-3063

    06/28/2022, 8:03 AM
    Quick question, with htmx can I put the trigger and get in the parent tag?
  • a

    ancient-father-3063

    06/28/2022, 8:09 AM
    So that the trigger will trigger of something happening in the child?
  • b

    blue-ghost-19146

    06/28/2022, 9:19 AM
    No, neither are inherited AFAIK
  • l

    lively-addition-84435

    06/28/2022, 10:25 AM
    I've got 2 filter forms on a page, that both replace parts of the page. The backend pushes URLs so that I get proper history. However both forms shall include all GET parameters currently in the URL bar, not only the own ones that are set through the element. Is there an easy way to do that with HTMX?
  • l

    lively-addition-84435

    06/28/2022, 10:28 AM
    Solved it. 😄 I can just include the values from the other form by adding
    hx-include="section.other [name]"
    . Jez, I love HTMX.
  • a

    ancient-father-3063

    06/28/2022, 10:56 AM
    Hey guys I just want to ask one more time, because I'm new at this, and I want to be sure before giving up.
  • a

    ancient-father-3063

    06/28/2022, 10:56 AM
    If I have a page with a table like this:
  • a

    ancient-father-3063

    06/28/2022, 10:58 AM
    Copy code
    html
    <table>
      <tr>
        <td>
          <select name="1" hx-trigger="" hx-get="" hx-target="other td">
            Bunch of options
          </select>
        </td>
        <td>
          <select name="2"></select>
        </td>
      </tr>
    </table>
  • a

    ancient-father-3063

    06/28/2022, 10:58 AM
    I want the selection of the td 1 to trigger the htmx and replace td2
  • a

    ancient-father-3063

    06/28/2022, 11:01 AM
    I don't think I can replace the whole table row, because the rest of the row has other forms that also might be updated by the user
  • b

    brave-dog-98297

    06/28/2022, 11:36 AM
    Is this what you're looking for: https://htmx.org/examples/value-select/
  • l

    late-king-98305

    06/28/2022, 12:02 PM
    👆 this... The example there shows the target as an ID, which is what I've always done (i.e.,
    <td id="theOtherCell">
    and
    hx-target="#theOtherCell"
    ). I haven't played with the relative targets much, but if you have control over the HTML and only one row in this scenario, going with IDs will fix it.
  • a

    ancient-father-3063

    06/28/2022, 12:07 PM
    Ah yes sorry, I forgot to elaborate. That code does work, but the problem is it relies on the name of the id.
  • a

    ancient-father-3063

    06/28/2022, 12:08 PM
    I can't hardcode the name of the id because these form fields (and their html) are being automatically generated (django model form), and I'm re-using the code in many places. @brave-dog-98297 @late-king-98305 .
  • b

    brave-dog-98297

    06/28/2022, 12:11 PM
    I find django model forms to be ok, but I always end up making my own using html and booptstrap. You get more control over what you call stuff and what goes into it. ID's etc.
  • l

    late-king-98305

    06/28/2022, 12:14 PM
    It's still a few hours before the Mountain Time guys are on here; have you tried
    next td
    or
    nearest td
    on the target? The docs don't say that should work, but I know there's been a lot of work put into that sort of thing to make scenarios like this "just work". (assuming you get the incantation right - LOL)
  • c

    cuddly-raincoat-38596

    06/28/2022, 12:15 PM
    Possible to use PKs of the entries as identifier? Otherwise you may use the current loop count. Anything like that
  • c

    cuddly-raincoat-38596

    06/28/2022, 12:17 PM
    {{forloop.counter}} Assuming you are using a for loop
  • a

    ancient-father-3063

    06/28/2022, 12:22 PM
    yeah the id's are all formulaic.
  • a

    ancient-father-3063

    06/28/2022, 12:23 PM
    I want the select with the id "id_matches-0-theirdeck" to target the tr with the id "matches-0-theirDeck"
  • a

    ancient-father-3063

    06/28/2022, 12:23 PM
    and then "id_matches-1-theirdeck" targets "matches-1-theirDeck"
  • a

    ancient-father-3063

    06/28/2022, 12:23 PM
    etc
  • a

    ancient-father-3063

    06/28/2022, 12:24 PM
    and I guess that number is ({{forloop.counter}} -1)
  • c

    cuddly-raincoat-38596

    06/28/2022, 12:24 PM
    pk is most likely cleaner.
  • a

    ancient-father-3063

    06/28/2022, 12:25 PM
    what's pk?
1...724725726...1146Latest