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

    big-airline-13935

    07/02/2020, 3:49 PM
    > this is a bit more radical, what if we switched to full colon separators and then recursively triggered events on the entire path: >
    Copy code
    > htmx:request:after
    > 
    > triggers events
    > 
    > htmx:request:after
    > htmx:request
    > htmx
    >
    Any thoughts on the above @User, @User ?
  • b

    big-airline-13935

    07/02/2020, 3:50 PM
    @User My initial feeling is that I would always want to target a specific event, rather than a type of event. Say I listen for the
    htmx:request
    , wouldn't that fire both before and after the request? And can I distinguish between the two?
  • s

    straight-van-46403

    07/02/2020, 3:59 PM
    i like the idea of namespaces. that seems really powerful. but in what @User is mentioning, i'd be worried about the recursive ramifications. perhaps an attribute on elements to exclude from triggering if needed
  • m

    most-jelly-15242

    07/02/2020, 5:43 PM
    Thanks for listening šŸ™‚ Yeah, the reason the events don't work in Alpine is because
    @htmx:afterRequest="console.log($event)"
    is seen as
    @htmx:afterrequest="console.log($event)"
    so the listener never sees the event. In the case of Alpine both
    htmx:after-request
    and
    htmx:request:after
    appear to work.
  • b

    big-airline-13935

    07/02/2020, 6:33 PM
    I think we're in agreement about the camelCase to kebab-case @User , @User was wondering whether it makes sense to "recursively trigger events on the entire path", of which I'm still on the fence about.
  • b

    big-airline-13935

    07/02/2020, 6:39 PM
    I do find that the syntax
    htmx:request:before
    and
    htmx:request:after
    is slightly more predictable than
    htmx:before-request
    and
    htmx:after-request
    and may offer more in the way of extensibility (
    htmx:request:before:process
    ,
    htmx:request:before:send
    , just thinking aloud here).
  • m

    most-jelly-15242

    07/02/2020, 6:53 PM
    I like the name spaced syntax. The ability to have the events triggered on the entire path sounds good to me as well. It provides flexibility and it's really up to the end user to decide whether they want to take advantage of this, or not. I suppose the entire path will be readable regardless of the step at which it's listened to? So when listening on
    htmx:request
    , you can check whether it's
    before
    or
    after
    ?
  • b

    big-airline-13935

    07/02/2020, 7:37 PM
    > So when listening on htmx:request, you can check whether it's before or after ? That's the part I'm unsure of...
  • m

    mysterious-toddler-20573

    07/02/2020, 9:18 PM
    we would pass the original event name along, for sure
  • m

    mysterious-toddler-20573

    07/02/2020, 9:18 PM
    as one of the
    event.detail
    values
  • m

    mysterious-toddler-20573

    07/02/2020, 9:19 PM
    Sure glad I stayed in the 0.0.x version space
  • m

    mysterious-toddler-20573

    07/02/2020, 9:19 PM
    current users get what they deserve!
  • b

    big-airline-13935

    07/02/2020, 10:04 PM
    > we would pass the original event name along, for sure In that case I'm all for it!
  • b

    big-airline-13935

    07/03/2020, 7:57 PM
    Does htmx interfere with anchor tags that point to elements on the same page? For example:
    Copy code
    html
    <a href="#me">ME #</a>
    
    <div id="me">Whatyouwannaknow</div>
    When the anchor tag is clicked, it appears to re-render the entire body...
  • b

    big-airline-13935

    07/03/2020, 8:01 PM
    See it happening at https://putyourlightson.com/sprig-cookbook (htmx@0.0.7). Seen this before @User?
  • u

    user

    07/04/2020, 7:37 AM
    @User How to cancel an event? In IC i could do
    settings.cancel = true
    in JS event. Here I'm using:
    Copy code
    window.addEventListener(
                    'beforeRequest.htmx',
                    function(e) {
                          if (somethingIsWrong) {
                              cancelRequest();
                          }
                    });
    So how to cancel that request? Doing
    e.details.xhr.abort()
    disables the XHR event completely, and it only fires once.
  • u

    user

    07/04/2020, 7:46 AM
    Should I go with
    e.preventDefault();
    and it will do just fine? šŸ˜„
  • u

    user

    07/04/2020, 1:08 PM
    Suddenly,
    beforeRequest.htmx
    and stuff changed to
    htmx:beforeRequest
    šŸ˜„
  • m

    mysterious-toddler-20573

    07/04/2020, 3:50 PM
    @User yeah, sorry about that :/
  • u

    user

    07/04/2020, 3:51 PM
    It's okay, we can always adapt in a programmer's world xD
  • m

    mysterious-toddler-20573

    07/04/2020, 3:51 PM
    I don't like changing APIs that drastically, but it is still 0.0.x
  • m

    mysterious-toddler-20573

    07/04/2020, 3:52 PM
    @User looking at the code
  • m

    mysterious-toddler-20573

    07/04/2020, 3:52 PM
    Are these boosted links?
  • m

    mysterious-toddler-20573

    07/04/2020, 3:53 PM
    It looks like we don't filter out anchor references in the boosting code
  • m

    mysterious-toddler-20573

    07/04/2020, 3:53 PM
    that's a bug
  • m

    mysterious-toddler-20573

    07/04/2020, 3:54 PM
    In here: https://github.com/bigskysoftware/htmx/blob/585055432f253fecffbbb56f8c47a7d833ae696b/www/js/htmx.js#L640 we shoudl be checking to see if the href begins w/ a hash
  • m

    mysterious-toddler-20573

    07/04/2020, 3:59 PM
    as a work around, if the elements are boosted, you can put a
    Copy code
    html
      <div hx-boosted="false">
        ....
      </div>
    around them for the time being
  • m

    mysterious-toddler-20573

    07/04/2020, 4:00 PM
    I actually use the intercooler equivalent of de-boosting pretty frequently in my main app
  • m

    mysterious-toddler-20573

    07/04/2020, 4:01 PM
    actually, I take that back, we do the right thing: https://github.com/bigskysoftware/htmx/blob/585055432f253fecffbbb56f8c47a7d833ae696b/www/js/htmx.js#L633
  • m

    mysterious-toddler-20573

    07/04/2020, 4:02 PM
    Copy code
    javascript
            function isLocalLink(elt) {
                return location.hostname === elt.hostname &&
                    getRawAttribute(elt,'href') &&
                    getRawAttribute(elt,'href').indexOf("#") !== 0;
            }
1...567...1146Latest