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

    mysterious-toddler-20573

    09/03/2020, 9:53 PM
    that's awesome
  • m

    mysterious-toddler-20573

    09/03/2020, 10:28 PM
    question for the crowd: in hyperscript, should
    a.b["c"].d
    be null safe? That is, if any of those values is null should the entire expression evaluate to null? TypeScript and some other languages have the elvis operator
    ?.
    but my sense is that, when you are on the front end and not doing business logic, you want non-side-effect dereference expressions to just return null if any of the elements are null
  • f

    flaky-television-51328

    09/03/2020, 10:53 PM
    Hi folks - trying to wrap my head around Sprig, htmx, hyperscript for a Craft CMS project. Not sure it's the right toolset, but feels like I'm close. I'm trying to pass settings from a spatial Javascript UI (x/y coordinates) to Sprig as search parameters. So far I have JS events updating the search component, but I can't figure out how to pass variables using htmx out of JS. A nudge in the right direction would be greatly appreciated.
  • m

    mysterious-toddler-20573

    09/03/2020, 11:04 PM
    How are you triggering the request?
  • f

    flaky-television-51328

    09/03/2020, 11:14 PM
    I'm triggering Sprig with
    document.getElementById('grid').dispatchEvent(new Event('refresh'));
    , but haven't figured out how to effectively use htmx yet.
  • m

    most-jelly-15242

    09/03/2020, 11:16 PM
    I recently found that you can use computed values
    hx-vars="coordinates:getCoordinates()"
    Maybe you can use that to read the coordinates?
  • m

    most-jelly-15242

    09/03/2020, 11:17 PM
    getCoordinates
    is a js function.
  • f

    flaky-television-51328

    09/03/2020, 11:20 PM
    Thanks @User - I have a number of variables I'd like to send, just trying to figure out the transport. I'm not an expert at js, so hard to figure out how to include hx-vars in the call back to Sprig. Sorry if I'm missing something obvious.
  • m

    most-jelly-15242

    09/03/2020, 11:22 PM
    I don't know if Sprig supports. This. You need to ask @User
  • m

    mysterious-toddler-20573

    09/04/2020, 1:20 AM
    Yep I’m sure we can figure something out. You might send the info up as one var that is JSON encoded. hx-vars is an option. A hidden input works too.
  • g

    gorgeous-ghost-95789

    09/04/2020, 1:25 AM
    Howdy @narrow-chef-14221 I wrestled with this same issue on a project, and ultimately decided to not use modals. It's probably a better design for mobile devices, anyway. With that said, you should be able to populate a modal DIV using a regular
    hx-get
    . Dismissing the modal might be a little more tricky, and might require you to use some custom Javascript to remove the modal content from the DOM when you're done. I'll try to make a little demo. It it works out well, I'll post it for you here.
  • g

    gorgeous-ghost-95789

    09/04/2020, 2:04 AM
    Hey, @User -- check out https://github.com/benpate/htmx-modal-example . It's not perfect, but it works with Bootstrap's CSS. It even trigger's Bootstrap's "fade out" effect when you close the dialog. With a little more work, I'm positive that I could get the fade-in to work properly as well.
  • g

    gorgeous-ghost-95789

    09/04/2020, 2:04 AM
    Of course, if you're not stuck using Bootstrap, HTMX has some nice features for animating objects when you load/unload them as well.
  • n

    narrow-chef-14221

    09/04/2020, 7:02 AM
    Thanks for the examples, guys! I'll check them out tomorrow and see what I can do.
  • b

    big-airline-13935

    09/04/2020, 3:18 PM
    @flaky-television-51328 It sounds like an input field (a hidden one or your search field) might be your best bet. Just use JS to set the value of the input field (which you can define in your Sprig component) to whatever you want it to be.
  • f

    flaky-television-51328

    09/04/2020, 4:00 PM
    Thanks @User! I like that approach. I'll give it a shot.
  • b

    big-airline-13935

    09/04/2020, 4:54 PM
    Let us know how it goes @flaky-television-51328
  • g

    gorgeous-ghost-95789

    09/04/2020, 9:02 PM
    Has HTMX determined the officially supported browsers (and versions)? For instance, is MSIE supported, even if Microsoft has finally EOL'ed it?
  • g

    gorgeous-ghost-95789

    09/04/2020, 9:03 PM
    I know this raises a lot of secondary issues, like how to make test cases for all kinds of browsers.
  • g

    gorgeous-ghost-95789

    09/04/2020, 9:05 PM
    The reason I'm asking, though, is that I noticed (and copied) some "helper" functions that look like ports from underscore.js, such as a
    forEach
    function that I think has been available in most evergreen browsers for a while now. If I could guarantee that this (or others) are available in all target browsers, then we could potentially shave a few hundred more bytes off of the library šŸ™‚
  • m

    mysterious-toddler-20573

    09/04/2020, 9:32 PM
    IE11
  • m

    mysterious-toddler-20573

    09/04/2020, 9:33 PM
    if it works in IE11, I'm good w/ it
  • m

    mysterious-toddler-20573

    09/04/2020, 9:33 PM
    at this point I'm maintaining IE11 support out of spite
  • g

    gorgeous-ghost-95789

    09/04/2020, 10:07 PM
    That's fair šŸ™‚
  • g

    gorgeous-ghost-95789

    09/04/2020, 10:08 PM
    (Fun story, I launched a web app in 2005 that didn't support IE. Told all of my users -- small business owners -- to switch to a different browser. I only ever lost one person because of it)
  • g

    gorgeous-ghost-95789

    09/04/2020, 10:09 PM
    But back to business, if it works in IE11 (and presumably recent-ish versions of Chrome, Safari, and Firefox) then it's fair game?
  • m

    mysterious-toddler-20573

    09/04/2020, 11:33 PM
    yep
  • a

    ancient-soccer-8576

    09/05/2020, 3:57 PM
    Hello, Just to say that I just started to learn htmx, it is really awesome. For prototype it saves tons of code compared to Vue is. Hope it will grow even docs are very good and web site is slim and fast. I am not really advanced but I like to play with new and anart technologies
  • m

    mysterious-toddler-20573

    09/05/2020, 5:12 PM
    great to hear @User I hope it is useful for you
  • m

    mysterious-toddler-20573

    09/06/2020, 12:49 AM
    my chaotic attempt to explain what happens during an htmx request:
1...232425...1146Latest