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

    echoing-lion-55988

    01/06/2023, 7:39 PM
    Is it possible to simulate with htmx?
  • g

    gorgeous-airport-54386

    01/06/2023, 7:39 PM
    yes
  • g

    gorgeous-airport-54386

    01/06/2023, 7:39 PM
    here's the code:
    Copy code
    html
    <a href="...">
  • t

    tall-dinner-62086

    01/06/2023, 7:39 PM
    What do you mean by that?
  • e

    echoing-lion-55988

    01/06/2023, 7:39 PM
    for example i want to have button, which after click, will redirect me to the other site
  • g

    gorgeous-airport-54386

    01/06/2023, 7:40 PM
    why does it have to be a button?
  • e

    echoing-lion-55988

    01/06/2023, 7:40 PM
    because i dont want to create a css class which will be the same as the button class πŸ˜›
  • g

    gorgeous-airport-54386

    01/06/2023, 7:40 PM
    if it's for aesthetic reasons, it's much preferable to use css
  • e

    echoing-lion-55988

    01/06/2023, 7:40 PM
    okay
  • e

    echoing-lion-55988

    01/06/2023, 7:40 PM
    i get it
  • e

    echoing-lion-55988

    01/06/2023, 7:40 PM
    damn you css
  • e

    echoing-lion-55988

    01/06/2023, 7:40 PM
    i wish css had more options to make it more reusable
  • r

    rich-television-50179

    01/06/2023, 7:40 PM
    I was getting ready to say you could use css to make the
    a
    element look like a button.
  • g

    gorgeous-airport-54386

    01/06/2023, 7:40 PM
    i think i have a class somewhere that normalizes buttons and links to look the same so you can add styling on top of that
  • e

    echoing-lion-55988

    01/06/2023, 7:41 PM
    i know i can do this that way
  • e

    echoing-lion-55988

    01/06/2023, 7:41 PM
    i was just curious
  • t

    tall-dinner-62086

    01/06/2023, 7:41 PM
    You could also use
    hx-get
    and return an
    HX-Redirect
    header, or you could just wrap the button in a get form
  • t

    tall-dinner-62086

    01/06/2023, 7:42 PM
    No need to get too fancy with it
  • e

    echoing-lion-55988

    01/06/2023, 7:42 PM
    wrapping button with form sounds like an idea
  • t

    tall-dinner-62086

    01/06/2023, 7:43 PM
    Just pretend it's 1999 again
  • e

    echoing-lion-55988

    01/06/2023, 7:43 PM
    xD
  • g

    gorgeous-airport-54386

    01/06/2023, 8:07 PM
    https://codepen.io/deniz-a/pen/oNMYmgy
  • l

    limited-potato-46306

    01/06/2023, 8:24 PM
    Thanks for looking over the changes and for your additions. A few thoughts: 1. The reason that I thought
    ajaxHelper
    was public is because of the comment here (https://github.com/croxton/htmx/blob/03c3e871313dcc73132d8a69de07ab6cbbe021be/src/htmx.js#L16). If indeed this function is public, then the variable
    path
    that we are using as the
    hxLocationHeaderPath
    will not always be tied to
    Hx-Location
    . Some extension using this function would probably break. This leads me to advocate for either changing the parameters that
    ajaxHelper
    takes OR, preferably, to not use that function when handling the
    Hx-Location
    header. @mysterious-toddler-20573 should this function be treated as public? 2. In terms of the main change from my code to yours where you pass the swap spec source element (https://github.com/croxton/htmx/blob/refactor/hx-location/src/htmx.js#L3058), I think the reason to do this is as you mentioned to "act like following a hx-boost link" by respecting other attributes on the element. While I believe you are correct that this would bring
    Hx-Location
    in line with the documentation, this is a bigger change that means making
    Hx-Location
    play nice with all the other attributes on the element. It is a good sign that existing tests pass, and I wonder, do we need any new tests? If new tests are required, could we make a PR with my changes and then a future PR with your change + new tests? 3. @hundreds-camera-24900 @mysterious-toddler-20573 In general, I wonder if the scope of
    Hx-Location
    is too big. Does it really need to have a callback that could be passed in via a header? I really appreciate you all looking into this - I love HTMX+Alpine as an alternative to Vue/React, and supporting use cases for the
    hx-history-preserve
    extension is vital to be able to ditch those frameworks.
  • e

    echoing-lion-55988

    01/06/2023, 9:06 PM
    yup, css option is the best
  • e

    echoing-lion-55988

    01/06/2023, 9:06 PM
    thank you for this awesome example
  • m

    mysterious-toddler-20573

    01/06/2023, 9:19 PM
    https://github.com/bigskysoftware/htmx/commit/666c6aa8e57ad986741adf85b6714d1d40c3d7e8
  • m

    mysterious-toddler-20573

    01/06/2023, 9:19 PM
    πŸ™‚ thank you, definitely feels like I'm not doing a great job
  • h

    hundreds-cartoon-20446

    01/06/2023, 9:21 PM
    @limited-potato-46306 1. I see, looks you are right. 2. It currently supports a source element if passed via the json in the header though, so attributes should already be supported. There isn’t a test for that though. Probably should be a separate PR as you say.
  • m

    mysterious-toddler-20573

    01/06/2023, 9:22 PM
    ajaxHelper
    is exposed at just
    htmx.ajax
  • m

    mysterious-toddler-20573

    01/06/2023, 9:22 PM
    @hundreds-camera-24900 do you have any thoughts on
    HX-Location
    here? I have to admit I'm not really up to speed yet.
1...972973974...1146Latest