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

    mysterious-toddler-20573

    07/14/2022, 1:08 AM
    It should do so automatically
  • c

    clever-dinner-48156

    07/14/2022, 1:18 AM
    Hi, when going to listen to websocket on every page, what is better, should we use
    hx-preserve
    or just let it be (will connect and disconnect on every page change)
  • m

    modern-smartphone-82132

    07/14/2022, 3:30 AM
    Hope someone can point me in the right direction. I have a form which I need populated. The first field has an hx-post which queries an Active Directory API and returns a JSON object with the values for the rest of the fields. What is the best approach to accomplish that? Hyperscript, Alpine vanilla JS etc?
  • a

    ancient-father-3063

    07/14/2022, 8:42 AM
    Copy code
    html
    <input class="form-check-input" type="checkbox" value="8" id="filteroutunplayed" hx-get="{% url 'statstable' %}" hx-target="#statstable" hx-swap="outerHTML">
  • a

    ancient-father-3063

    07/14/2022, 8:43 AM
    I was expecting this request.GET to have a value of 8
  • a

    ancient-father-3063

    07/14/2022, 8:43 AM
    but instead it's just empty
  • a

    ancient-father-3063

    07/14/2022, 8:44 AM
    what's up with that?
  • t

    tall-dinner-62086

    07/14/2022, 9:39 AM
    You didn't actually name your input
  • m

    modern-smartphone-82132

    07/14/2022, 10:45 AM
    You need to pass the value along with the get request as hx-vals='{"my_value":"'8"}' then pick it up in the view as request.GET.get('my_value') <- Thought I was in the django chat. Whichever method you do to extract the passed along variable on the server side is what you have to do.
  • a

    ancient-father-3063

    07/14/2022, 12:58 PM
    Ah yeah, that's it, things have to have a name. Thanks
  • a

    ancient-father-3063

    07/14/2022, 12:59 PM
    Thanks for the reply, but I wasn't really clear in my question. I don't actually want to hard code '8' in there, I just want to know if the box is checked or not. I'm sure I'm supposed to change it to 'true' or something, I don't know how checkboxes work yet
  • m

    mysterious-toddler-20573

    07/14/2022, 1:00 PM
    checkboxes will include their value if they are checked. If they are not checked, no value will be sent. Kind of annoying, but that's the way they work.
  • f

    fancy-elephant-10660

    07/14/2022, 1:09 PM
    Maybe one missing element is a different django template engine that works more like VUE templating. instead of writing {{ include "someComponent.html" }} you could write </... How hard would it be to write such a templating language for Django?
  • i

    important-van-94053

    07/14/2022, 1:13 PM
    This was mentioned a few days ago: https://tcom.scaletti.dev/
  • t

    tall-dinner-62086

    07/14/2022, 1:19 PM
    > Millions of people clicked a button in the last week alone!
  • p

    powerful-helmet-42757

    07/14/2022, 1:30 PM
    I'm using
    boost
    to navigate trough one of my site and I want to run some Js each time a new page loads. Is
    htmx:load
    a good event to listen to? Maybe combined with checking the
    HX-Boosted
    header? I'm relatively OK with that but I'm curious to see other solutions.
  • m

    mysterious-toddler-20573

    07/14/2022, 1:34 PM
    htmx has an
    onLoad
    function that allows you to execute some javascript every time new content is loaded into the DOM via an htmx-driven request, akin to the jQuery
    ready
    function: https://htmx.org/docs/#3rd-party
  • p

    powerful-helmet-42757

    07/14/2022, 1:39 PM
    Will try. The trick here is that I'm using a function to sync some
    select
    with url params. I want to sync them when landing or navigating to the page, but not each time htmx
    load
    stuff, since all of these
    select
    already trigger
    hx-get
    .
  • p

    powerful-helmet-42757

    07/14/2022, 1:40 PM
    So I kinda need to know if the
    load
    comes from a
    boost
  • m

    mysterious-toddler-20573

    07/14/2022, 1:40 PM
    mmm, interesting
  • m

    mysterious-toddler-20573

    07/14/2022, 1:40 PM
    one sec, lemme look at the code
  • m

    mysterious-toddler-20573

    07/14/2022, 1:42 PM
    OK, as it stands it's hard to tell when a boosted link is clicked
  • p

    powerful-helmet-42757

    07/14/2022, 1:42 PM
    You can see the result here (without the param synching part)
  • m

    mysterious-toddler-20573

    07/14/2022, 1:42 PM
    we should have an event for that
  • p

    powerful-helmet-42757

    07/14/2022, 1:43 PM
    That would be great
  • p

    powerful-helmet-42757

    07/14/2022, 1:44 PM
    In the meantime I'll see if I can do something on my end with
    htmx.load
    and headers.
  • p

    powerful-helmet-42757

    07/14/2022, 1:54 PM
    Also, by adding a
    selected
    attribute to an
    option
    , HTMX will keep the selected value in the memory cache. This kinda fixes it for me. I get my synched
    select
    when initially loading the page, and values are kept when using navigating
    back
    and
    forward
    .
  • a

    acoustic-autumn-94211

    07/14/2022, 1:58 PM
    Yep - sure does - my bad - I was messing around last night to see if it worked and didn't have things setup right - thanks!
  • l

    late-king-98305

    07/14/2022, 2:08 PM
    Giraffe.Htmx (F# web server) now supports v1.8.0! https://github.com/bit-badger/Giraffe.Htmx/releases/tag/v1.8.0
  • b

    brave-dog-98297

    07/14/2022, 2:26 PM
    Hi guys, wierd situation. I have a page that utilizes lazy loading on a couple of fields, which was all working well. Then I made another page that does the same thing with similar content (same django model, different views, urls, templates). Now my first page is trying to fetch it's original urls and those of the second page. Can we not lazy load on several pages? I thought the code on the page would only execute within itself, not project wide.
1...744745746...1146Latest