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

    ancient-father-3063

    07/03/2022, 10:51 PM
    Its triggering off a form field, so I want the GET request to include the normal parameter that has the fields value, but also a custom parameter.
  • a

    ancient-father-3063

    07/03/2022, 10:52 PM
    or ideally, I'd like to just be able to rename the default parameter key. so that the GET request looks like:
  • a

    ancient-father-3063

    07/03/2022, 10:52 PM
    "GET /url/?customparameter=formfieldvalue"
  • a

    ancient-father-3063

    07/03/2022, 10:53 PM
    is that possible?
  • a

    ancient-father-3063

    07/03/2022, 11:00 PM
    Copy code
    html
    hx-params="loadx"
  • a

    ancient-father-3063

    07/03/2022, 11:01 PM
    I tried sticking this in, but this replaces the default parameter (the form value) which I still need
  • a

    ancient-father-3063

    07/03/2022, 11:01 PM
    Really I just need a way for my backend to be able to differentiate between this htmx innitiating the GET request and a different htmx GET request
  • a

    ancient-father-3063

    07/03/2022, 11:39 PM
    I could also solve this by writing a new view on my backend just for this case. But I wanted to check here first if there's another way
  • w

    white-motorcycle-95262

    07/04/2022, 1:30 AM
    What's the difference between
    htmx:beforeRequest
    and
    htmx:beforeSend
    ? I'm trying to put the various major HTMX events "in order" to help create a HTMX progress bar in Hyperscript. I'm thinking: 1) beforeRequest 2) beforeSend (?) 3) afterRequest 4) beforeProcessNode (?) 5) afterProcessNode (?) 5) beforeSwap 6) afterSwap 7) afterSettle the idea being that hyperscript would increment the progress bar by 1/n, where n is the number of steps. I just saw the
    htmx:xhs:progress
    event, but I'm not sure about the specifics of that, or if it would be applicable to fetching HTML from a server running Django.
    m
    • 2
    • 12
  • w

    white-motorcycle-95262

    07/04/2022, 2:27 AM
    HTMX Progress Bar
  • m

    mysterious-toddler-20573

    07/04/2022, 3:04 AM
    it sounds like maybe you want to look at the headers that htmx sends?
  • m

    mysterious-toddler-20573

    07/04/2022, 3:04 AM
    https://htmx.org/reference/#request_headers
  • m

    mysterious-toddler-20573

    07/04/2022, 3:04 AM
    alternatively, you can use the https://htmx.org/events/#htmx:configRequest event to do whatever you'd like to the parameters that htmx sends
  • a

    ancient-father-3063

    07/04/2022, 3:28 AM
    @mysterious-toddler-20573 thanks, I'll look into it
  • a

    ancient-father-3063

    07/04/2022, 4:44 AM
    How do I use HX-Trigger-Name? is that in addition to hx-trigger or does it replace it?
  • b

    bland-coat-6833

    07/04/2022, 4:39 PM
    Htmx getting a name check on this podcast: https://www.pythonpodcast.com/tetra-full-stack-component-web-framework-episode-369/
  • b

    bland-coat-6833

    07/04/2022, 4:39 PM
    LoB in particular
  • p

    powerful-train-54786

    07/04/2022, 7:34 PM
    I'm trying to do a dynamically sorted form component and want to have the post params to simply be a json value with an array of objects (ie
    {formvalues: [{value: "input 1", type: "h1"}, ...]}
    I know there's the htmx:configRequest, but I essentially want instead of just using
    hx-post
    I want to do some pre-processing and do the hx-post after manually collecting that data
  • p

    powerful-train-54786

    07/04/2022, 9:17 PM
    would this be the way?
    <div hx-get="/example" hx-vals='js:{myVal: calculateValue()}'>Get Some HTML, Including a Dynamic Value from Javascript in the Request</div>
  • g

    gray-morning-3453

    07/05/2022, 5:31 AM
    Is there a way to create pretty urls on client side dynamically using hx-vals? Something which caters to a django url like: ``calendar////`` The variables year, month, day have to be dynamically created by script on client side upon page load.
  • r

    ripe-action-67367

    07/05/2022, 6:09 AM
    Why can't you create them server-side?
  • r

    ripe-action-67367

    07/05/2022, 6:18 AM
    Putting that question aside, you could use https://htmx.org/events/#htmx:configRequest event to customize the path. The docs seems to be a little outdated, but according to source code you should be able to change the path of the request https://github.com/bigskysoftware/htmx/blob/master/src/htmx.js#L2633-L2644
  • s

    some-diamond-25050

    07/05/2022, 9:49 AM
    https://github.com/bigskysoftware/htmx/discussions/951 refer otpmodal.html the close button is not dismissing modal dialog. I have tried adding type=button attribute also.
  • g

    gorgeous-ghost-95789

    07/05/2022, 2:25 PM
    I don’t have a chance to dig into this too deeply, but you’ll need to see that your client-side code is catching the events that are triggered by the server. One common problem is WHERE they’re triggered. By default, any event listeners you put in an element will listen on that element (and children) but events triggered in a response header only show up on the body. It make sense, but it’s an easy thing to miss. Use
    from:body
    to listen to the right location.
  • p

    powerful-train-54786

    07/05/2022, 10:35 PM
    Are there any general ideomatic htmx strategies for doing things like adding things to lists. I'm making a dynamic form builder and was thinking either just handle it plain JavaScript, or whatever I keep some data of the state of the list on the page and as I update the data, post and return the new form.
  • m

    mysterious-toddler-20573

    07/06/2022, 12:30 AM
    depends a bit on how your HTML is structured and how much complexity you are willing to tolerate. Generally the progression goes: * replace the whole UI * use OOB swaps * use custom events https://htmx.org/examples/update-other-content/
  • w

    white-motorcycle-95262

    07/06/2022, 1:26 AM
    I've figured out the cause of the issue with boosted anchors on target pages + history (https://github.com/bigskysoftware/htmx/issues/827) EDIT: I've written up my findings above and I'm willing to submit a PR if I could get a little more guidance. Thanks 🙂
    m
    • 2
    • 22
  • w

    white-motorcycle-95262

    07/06/2022, 2:19 AM
    Just an FYI, I'm working on fixing this issue: https://github.com/bigskysoftware/htmx/issues/827
  • w

    white-motorcycle-95262

    07/06/2022, 2:21 AM
    FYI, I believe your comment is related to https://github.com/bigskysoftware/htmx/issues/827
  • p

    powerful-train-54786

    07/06/2022, 2:23 AM
    I'll look into this. for now I went with having a target within the form and I hx-swap: beforeend to that, and the route just returns the element of my choosing. I'll use hyperscript for the other dynamic operations like remove/move around since it's simple form building. In my case I'm building a form as opposed to using the form to add elements so I think my direction is good, but I'll read through that example
1...734735736...1146Latest