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

    mysterious-toddler-20573

    09/14/2020, 9:06 PM
    Locality of behavior, for scripting events: https://htmx.org/essays/locality-of-behaviour/
  • m

    mysterious-toddler-20573

    09/14/2020, 9:06 PM
    (I admit it is easier to read than to write, but that's the idea)
  • b

    big-airline-13935

    09/14/2020, 9:07 PM
    A small DevX request of mine would be to bring the public API up to the top of the file, like with the recent change in htmx (https://github.com/bigskysoftware/htmx/blob/dev/src/htmx.js#L14). Makes the code easier to scan.
  • w

    wooden-wall-85896

    09/14/2020, 9:07 PM
    Got it.
  • w

    wooden-wall-85896

    09/14/2020, 9:08 PM
    Layering it on top is something optional I think is a great way to do it
  • b

    big-airline-13935

    09/14/2020, 9:08 PM
    I could PR that if you agree @User ?
  • m

    mysterious-toddler-20573

    09/14/2020, 9:09 PM
    yep, works for me
  • m

    mysterious-toddler-20573

    09/14/2020, 9:10 PM
    Yes, I don't want hyperscript to be required. I'd like for it to demonstrate it's own value vs javascript and then people can reach for it at that point.
  • m

    mysterious-toddler-20573

    09/14/2020, 9:11 PM
    otoh, I wanted it there to take pressure off adding things into htmx that are tempting but probably don't belong there (e.g. toggling classes on elements)
  • m

    mysterious-toddler-20573

    09/14/2020, 9:11 PM
    so if someone wants something that isn't a core part of htmx, I can say "well, you could use hyperscript or AlpineJS to do that"
  • b

    big-airline-13935

    09/14/2020, 9:12 PM
    Or vanilla JS 😉
  • m

    mysterious-toddler-20573

    09/14/2020, 9:14 PM
    or vanillaJS
  • m

    mysterious-toddler-20573

    09/14/2020, 9:14 PM
    the event model is open to all comers
  • m

    mysterious-toddler-20573

    09/14/2020, 9:14 PM
    as with the server side, we are firmly in the HOWL camp: HTML On Whatever you'd Like
  • m

    mysterious-toddler-20573

    09/14/2020, 9:18 PM
    Copy code
    js
    target.addEventListener('click', function(event){  
      target.classList.add('foo')})
      setTimeout(function () { 
        target.classList.remove('foo')
      }, 3000);
    });
  • m

    mysterious-toddler-20573

    09/14/2020, 9:18 PM
    the equivalent vanilla JS
  • m

    mysterious-toddler-20573

    09/14/2020, 9:20 PM
    or, I suppose:
    Copy code
    html
    <button onclick="this.classList.add('foo'); setTimeout(function () {this.classList.remove('foo')}, 3000);">
    Click Me
    </button>
  • m

    mysterious-toddler-20573

    09/14/2020, 9:21 PM
    and the hyperscript can be reduced to:
    Copy code
    html
     <button _="on click add .foo then wait 3s then remove .foo">Click Me</button>
  • m

    mysterious-toddler-20573

    09/14/2020, 9:22 PM
    and hyperscript, like AlpineJS, can respond to any events, not just the ones mentoned in the html spec, etc.
  • m

    mysterious-toddler-20573

    09/14/2020, 9:22 PM
    anyway, goal is an embeddable scripting language that reads easily
  • m

    mysterious-toddler-20573

    09/14/2020, 9:23 PM
    we'll see how it turns out
  • m

    mysterious-toddler-20573

    09/14/2020, 9:23 PM
    (rambling, but this is interesting to me)
  • g

    gorgeous-iron-50959

    09/15/2020, 4:07 PM
    How do initialize the hyperscript code that comes in from a htmx request. Hyperscript doesn' seem to know it exists unless you run hyperscript.start() again?
  • m

    mysterious-toddler-20573

    09/15/2020, 4:14 PM
    @User it should "just work"
  • m

    mysterious-toddler-20573

    09/15/2020, 4:14 PM
    If it isn't, can I ask you to wait about a week until the next release of htmx and hyperscript?
  • m

    mysterious-toddler-20573

    09/15/2020, 4:14 PM
    I have reworked the integration and it is much cleaner :/
  • m

    mysterious-toddler-20573

    09/15/2020, 4:14 PM
    sorry
  • m

    mysterious-toddler-20573

    09/15/2020, 4:15 PM
    Oh, wait, one sec
  • m

    mysterious-toddler-20573

    09/15/2020, 4:15 PM
    do you have a local copy of htmx.js?
  • m

    mysterious-toddler-20573

    09/15/2020, 4:16 PM
    You may need this change:
    Copy code
    js
            function findElementsToProcess(elt) {
                if (elt.querySelectorAll) {
                    var results = elt.querySelectorAll(VERB_SELECTOR + ", a, form, [hx-sse], [data-hx-sse], [hx-ws]," +
                        " [data-hx-ws], [_], [script], [data-script]");
                    return results;
                } else {
                    return [];
                }
            }
1...293031...1146Latest