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

    mysterious-toddler-20573

    11/02/2020, 5:58 PM
    You have a few options
  • m

    mysterious-toddler-20573

    11/02/2020, 5:59 PM
    1: expand the target to encompase all the UI that needs to be updated. This isn't as bad as it sounds since we do a pretty good merge between the old UI state and the new one.
  • m

    mysterious-toddler-20573

    11/02/2020, 5:59 PM
    2: use out of band updates https://htmx.org/docs/#oob_swaps
  • m

    mysterious-toddler-20573

    11/02/2020, 5:59 PM
    3: use a response header to trigger requests
  • m

    mysterious-toddler-20573

    11/02/2020, 6:00 PM
    4: use the "path deps" extension: https://htmx.org/extensions/path-deps/
  • m

    mysterious-toddler-20573

    11/02/2020, 6:01 PM
    I tend to lean towards 1 until I really need a better experience or specific UI
  • u

    user

    11/02/2020, 6:02 PM
    I usually go with 3) - pretty easy, and you can store your functions (and call them) separately
  • a

    ancient-soccer-8576

    11/02/2020, 6:03 PM
    I think 1 is the same approach of alpine as well with variable scope (where you put the x-data) or am i wrong?
  • a

    ancient-soccer-8576

    11/02/2020, 6:04 PM
    And 3 uh oh... it is starting to blow my mind... use response headers? didnt even know about them
  • a

    ancient-soccer-8576

    11/02/2020, 6:05 PM
    oh wait... in 1 you give back all the GUI, not just what is updated... isnt this a waste of bandwidth?
  • m

    mysterious-toddler-20573

    11/02/2020, 6:58 PM
    > oh wait... in 1 you give back all the GUI, not just what is updated... isnt this a waste of bandwidth? @User to an extent, but compared to the network setup costs and all the images and video flying around, it's a round off error
  • m

    mysterious-toddler-20573

    11/02/2020, 6:59 PM
    in most cases
  • a

    ancient-soccer-8576

    11/02/2020, 7:42 PM
    And the approach 3 is there an example? I just advice to add some more complex samples in the docs... Like the hxinclude directive
  • g

    gorgeous-ghost-95789

    11/02/2020, 8:04 PM
    Hey @ancient-soccer-8576 Check out https://htmx.org/headers/x-hx-trigger
  • g

    gorgeous-ghost-95789

    11/02/2020, 8:05 PM
    That’s the header that you return to trigger additional client-side events.
  • a

    ancient-soccer-8576

    11/02/2020, 10:08 PM
    > That’s the header that you return to trigger additional client-side events. @gorgeous-ghost-95789 thank you I will try. I don't get either how I can pass a value in hx-include for a post request.
  • g

    gorgeous-ghost-95789

    11/02/2020, 10:10 PM
    I haven’t had to do that either, yet. Most of my work is in GETs or straight form POSTs. It should be straightforward.
  • m

    mysterious-toddler-20573

    11/03/2020, 1:41 AM
    @User and @User don't think I've given up on your pull requests, just slammed right now
  • g

    gorgeous-ghost-95789

    11/03/2020, 3:15 AM
    Of course not. I’ve been busy too, which is why a simple demo took me a month to do.
  • g

    gorgeous-ghost-95789

    11/03/2020, 3:15 AM
    But, let me know if you need more docs written and I’ll try to add them to my list.
  • l

    late-tent-52036

    11/03/2020, 7:07 AM
    Hi folks! Having great first impressions with htmx - feels nice. I'm just doing some basic experimenting to remove items from a list which works great. Accepting the details and responding with "nothing" works great - However in certain scenarios when the post to the backend to delete an item is stale/malformed/broken for whatever reason I would want to respond back with the full page load to resync everything backup - but am stuck on how to best approach that as by default it will want to add the whole page in my targeted element. Do I need to set a custom response header to also listen for on my page to then trigger as refresh ? Just a bit stuck on how to approach with just the library?
  • m

    most-jelly-15242

    11/03/2020, 1:50 PM
    @User You can use the HX-Trigger header and listen to your event to reload the page. There's an example in the docs using hyperscript https://htmx.org/docs/#hyperscript, but you can also use a regular JS event listener. In your case, instead of
    redirect
    , you can trigger a
    reload
    event and listen to that to run
    location.reload()
  • c

    clean-kitchen-15473

    11/03/2020, 6:53 PM
    Is it possible to send values of tags that aren't forms? IE I'm using the list-group from bootstrap to simulate a select tag and I want to send the value of the "active" - do you just set the 'name' tag of the item u want to send?
  • m

    mysterious-toddler-20573

    11/03/2020, 7:04 PM
    can you post some html
  • c

    clean-kitchen-15473

    11/03/2020, 7:08 PM
    Copy code
    html
    
    <a class="list-group-item list-group-item-action"
       id="#qPestImages.asv_key#" 
       data-toggle="list" 
       href="##list-#qPestImages.asv_key#" 
       role="tab" 
       aria-controls="#qPestImages.asv_key#">
    
    <img style='object-fit:cover; height:50px; width:50px' src='#APPLICATION.URL_DAM##qPestImages.imagePath#'></img>
    <span class='pl-2'>#qPestImages.asv_caption#</span>
     
    </a>
    Im outputting a list of these to click on which is basically this https://getbootstrap.com/docs/4.0/components/list-group/#javascript-behavior I want to try to send the one I click to the backend
  • m

    mysterious-toddler-20573

    11/03/2020, 7:21 PM
    OK, so you could then put an hx-post or whatever on them and then use
    hx-vars="id:'whatever-the-id-is'"
    as well, to include the id variable in the request: https://htmx.org/attributes/hx-vars/
  • l

    late-tent-52036

    11/03/2020, 11:57 PM
    So using a combination of hx-post and hx-vars you could build a "form" on single element forgoing any tag and end up with something that will ajax post with form data ?
  • m

    mysterious-toddler-20573

    11/04/2020, 12:43 AM
    yes
  • m

    mysterious-toddler-20573

    11/04/2020, 12:44 AM
    You can also include a form from somewhere else with the
    hx-include
    parameter, if you would prefer that https://htmx.org/attributes/hx-include/
  • m

    mysterious-toddler-20573

    11/04/2020, 12:44 AM
    But you just want to encode name/value pairs to be sent up with a given request,
    hx-vars
    works well
1...686970...1146Latest