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

    great-cartoon-12331

    04/29/2023, 10:02 PM
    the backend is correctly setting a mime-type but htmx is ignoring it and rendering the contents as html
  • g

    great-cartoon-12331

    04/29/2023, 10:03 PM
    i'm probably doing something it's not meant to do!
  • r

    refined-waiter-90422

    04/29/2023, 10:39 PM
    Oh dang that's nice. Only downside- editor support probably 2030 ๐Ÿ˜‰ as usual. That said it will make it a heck of a lot easier to implement in editors.. i actually have to detect the content in the string to highlight currently
  • r

    refined-waiter-90422

    04/29/2023, 10:40 PM
    the one bonus of the current way is less verbosity.. just use your fstrings, but still good to see an official PEP.
  • r

    refined-waiter-90422

    04/29/2023, 10:41 PM
    hilarious/cool to see guido himself addressing the exact same pain points of embedded sql / html / shell
  • r

    refined-waiter-90422

    04/29/2023, 10:41 PM
    that's good!!
  • b

    bitter-machine-55943

    04/29/2023, 10:51 PM
    I wonder if thatโ€™s a slippery slope, if Python now has to keep up with SQL/HTML/SH parsing, and that list will grow. Instead it seems like if they had a way to generalize f-strings, where you can define whatever โ€œfโ€ you want
  • r

    refined-waiter-90422

    04/29/2023, 10:52 PM
    i'm assuming it's just a token/placeholder so the editors know what language to detect and catch up? I don't dare derail the PEP or else we may never get embedded languages in editors.
  • r

    refined-waiter-90422

    04/29/2023, 10:54 PM
    tooling determining the evolution of our languages, yet again lol
  • m

    mysterious-toddler-20573

    04/30/2023, 1:46 AM
    can you do a client side redirect to the download URL using
    HX-Redirect
    response header? And then show an error message w/
    HX-Trigger
    response header?
  • g

    great-cartoon-12331

    04/30/2023, 1:47 AM
    oh interesting, a slightly indirect approach, yeah could work. will try that out soon
  • p

    proud-librarian-99598

    04/30/2023, 8:44 AM
    Is it possible to add an event filter that refers to the current element? Something like
    hx-trigger="sl-selection-change[detail.selection.includes(thisElement)] from:body"
    where
    thisElement
    would be the element that the
    hx-trigger
    is defined on.
  • p

    proud-librarian-99598

    04/30/2023, 8:57 AM
    As an alternative, I found I can use this bit of glue code in JavaScriipt:
    Copy code
    let tree = document.getElementById('repositories-tree');
        tree.addEventListener('sl-selection-change', event => {
            event.detail.selection.forEach(it => {
                htmx.trigger(it, 'do-it');
            });
        });
    I am just wondering why I need to pass in an event name. I don't have
    hx-trigger
    on the element itself. I just want to trigger the htmx behaviour. If I do
    htmx.trigger(it)
    , there is a JavaScript error.
  • m

    mysterious-toddler-20573

    04/30/2023, 6:13 PM
    I think we should invoke the event filter w/ the
    this
    symbol set to the element it is defined on
  • m

    mysterious-toddler-20573

    04/30/2023, 6:13 PM
    I will try to add that soon
  • m

    mysterious-toddler-20573

    04/30/2023, 6:13 PM
    sorry about that @proud-librarian-99598
  • p

    proud-librarian-99598

    04/30/2023, 6:26 PM
    Thanks, that would be great
  • n

    numerous-application-19425

    05/01/2023, 12:28 AM
    Hi, I have question about the performance of 100+ unique elements, each with a unique
    hx-trigger
    custom event This listens for a HX-Trigger
    moGetBookmarkButton_ID
    event on the
    div#bookmark_item_*
    element to trigger a
    hx-get
    Copy code
    php
    kirby()->response()->header('HX-Trigger','moGetBookmarkButton_' . $product->id())
    //eg: kirby()->response()->header('HX-Trigger','moGetBookmarkButton_b2')
    The HTML in Pug template language to keep it short.
    Copy code
    pug
    - var values = { a1: 'Item A', b2: 'Item B', d4: 'Item 4' };
    each item, id in values
        div(id=`bookmark_item_${id}`,hx-get=`bookmark/${id}`,hx-trigger=`moGetBookmarkButton_${id} from:body`)= item
        //- eg: div(id=`bookmark_item_b2`,hx-get=`bookmark/b2`,hx-trigger=`moGetBookmarkButton_b2 from:body`)= item
    Pro: transparent code, no extra JS Contra: **How performant is this, in a list of 100
    #bookmark_item_*
    elements with 100
    hx-trigger="moGetBookmarkButton_*"
    listening?** This was my first solution and it seems to work well. I thought about two other solutions, that have drawbacks and become more complex, but are maybe worth to explore. I laid them all out here: https://gist.github.com/marcus-at-localhost/6e235888514fb081b56cc0ee7c72a888 V1 is definitively the most simple solution and probably preferable. What do you think? (I don't know if I can fake
    HX-Trigger
    headers through the demo.htmx.org else I would have build a JsFiddle)
  • m

    mysterious-toddler-20573

    05/01/2023, 12:37 AM
    if it performs (test it on weak hardware) then I like the visibility of this approach
  • m

    mysterious-toddler-20573

    05/01/2023, 2:36 PM
    https://htmx.org/essays/two-approaches-to-decoupling/
  • n

    numerous-application-19425

    05/01/2023, 6:13 PM
    Works remarkedly well in my test. Thanks for giving it a look!
  • m

    mysterious-toddler-20573

    05/01/2023, 6:30 PM
    ๐Ÿ™‚ good to hear. Computers are fast!
  • j

    jolly-waitress-42858

    05/01/2023, 8:09 PM
    does anyone know how to get started with building something like this - https://reactflow.dev/ - in htmx ? should i be looking at building this from scratch ? or can react-flow somehow be repurposed into htmx ?
  • b

    bitter-machine-55943

    05/01/2023, 9:25 PM
    Are you wanting to use this from an HTMX app? Or you want to create a clone of this kind of app using HTMX?
  • j

    jolly-waitress-42858

    05/01/2023, 9:35 PM
    If I can use react-flow from HTMX...that would be awesome. However I'm not sure if that is possible. My backend is java. Failing which, i would like to build something similar (or use one if available)
  • b

    bitter-machine-55943

    05/01/2023, 9:38 PM
    If you can use React in your app then you can use it. Like people use React in Django. Like you might have to build the React part to static content then use that HTML/CSS/JS from your Java backend
  • j

    jolly-waitress-42858

    05/01/2023, 9:48 PM
    Ah I would prefer to not pull the whole react toolchain. Which is also why I'm using htmx. Just wanted to see if there are existing libraries that did this in htmx
  • b

    bitter-machine-55943

    05/01/2023, 10:02 PM
    You can import React from CDN. Not sure if thatโ€™s a good idea or not
  • n

    numerous-application-19425

    05/02/2023, 1:35 AM
    Hi I built a little demo (https://codepen.io/localhorst/pen/oNaeVqZ) how to use the bootstrap toasts component with HTMX and custom triggers. Toasts are stackable and grouped by message (so the same message doesn't pop up several times, when already open.) Might be a good starting point. Check out the network tab in dev tools, to see the
    HX-Trigger
    I'm happy to see improvements. Is there something like a HTMX demo collection (beside the official one)? Here are a few of my demos: https://codepen.io/collection/BNVjqp

    https://cdn.discordapp.com/attachments/725789747212976259/1102770304415191131/image.pngโ–พ

  • m

    mysterious-toddler-20573

    05/02/2023, 3:10 AM
    probably a little too academic to make waves, but the decoupling essay is on the front page of ๐ŸŸ 

    https://cdn.discordapp.com/attachments/725789747212976259/1102794287290265673/image.pngโ–พ

1...110911101111...1146Latest