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

    late-king-98305

    08/31/2022, 3:25 PM
    It could generalize outside that if there was a way to parse HTML to its nodes; there may be, but I haven't played in that space in a while. Razor doesn't build up the tree like that, so it wouldn't translate there.
  • l

    late-king-98305

    08/31/2022, 3:27 PM
    I have a thought - I'll send it there.
  • l

    late-king-98305

    08/31/2022, 5:40 PM
    This crossed my feed earlier, and I thought it was appropriate re: links and buttons https://twitter.com/AshleeMBoyer/status/1564345238004588544
  • l

    late-king-98305

    08/31/2022, 5:43 PM
    And props to her for pitching her new "article" instead of "blog." One day we will rid the web of the scourge of conflating articles and blogs; then, we shall take up the mantle of episodes and podcasts! 👏
  • a

    adamant-salesmen-67924

    08/31/2022, 6:24 PM
    Got an answer for you now, yes you can. In the
    $Latte_Engine->render()
    or
    ->renderToString()
    there is a 3rd method argument to only render a particular block in the template you are specifying. The answer was so obvious I didn't see it XD https://forum.nette.org/en/35395-template-fragments-in-latte#p221040 So
    $Latte_Engine->render('path/to/template.latte', [ 'foo' => 'bar' ], 'footer');
    will only render the footer block out of the template.
  • e

    enough-spoon-36360

    08/31/2022, 7:06 PM
    Hi there! I just joined discord and I had a concern: Is there a way to make an HTML element with HTMX attributes work as an HTMX endpoint response? I've been trying and the new element appended, is not triggered by the event specified
  • e

    enough-spoon-36360

    08/31/2022, 8:09 PM
    Hi there! I just joined discord and I had a concern: Is there a way to make an HTML element with HTMX attributes from an HTMX endpoint response? I've been trying and the new element appended, is not triggered by the event specified
  • g

    gifted-london-36179

    08/31/2022, 11:20 PM
    Would you be able to share how you got HTMX and DataTables to work together? Did you use htmx.process() or something like that? I'm trying to pass a template into the tbody of a table with hx-get but it stops working when I introduce DataTables
  • t

    tall-river-23601

    09/01/2022, 7:41 AM
    Hi there htmx community. I just read about the fragments-rendering approach and think about integrating it into our Python based HTML rendering engine (https://github.com/basxsoftwareassociation/htmlgenerator). I saw that the fragments use separate names and I am now wondering what the advantages or disadvantages would be if I would allow to select html-tag, class or any attributes instead of a separate naming scheme. Any feedback on that idea?
  • b

    brave-dog-98297

    09/01/2022, 8:45 AM
    A little hyperscipt to process the node works for me. This is on a button that injects new html which includes hyperscript and htmx code.
    Copy code
    _="on click 
          ...
          then call htmx.process(last <.item/>)
          then call _hyperscript.processNode(last <.item/>)"
  • f

    fierce-application-41107

    09/01/2022, 9:09 AM
    Hi everyone, I'm using gridstack to dynamically add widgets containing HTMX code, it seems to work on first load, but when I swap out the widget with HTMX and then add it with the .addWidget API, it seems that the JS events are not created on the elements for HTMX
  • f

    fierce-application-41107

    09/01/2022, 9:10 AM
    I have this for the initial load: https://0x0.st/opVH.txt table_results: https://0x0.st/opVX.txt
  • f

    fierce-application-41107

    09/01/2022, 9:10 AM
    IMO it shouldn't even work on first load but hey
  • f

    fierce-application-41107

    09/01/2022, 9:11 AM
    The part that swaps results is:
    Copy code
    hx-target="#results"
            hx-swap="innerHTML"
  • f

    fierce-application-41107

    09/01/2022, 9:11 AM
    it swaps it with the content of table_results above
  • f

    fierce-application-41107

    09/01/2022, 9:12 AM
    so in my mind it's doing exactly the same thing on first load as on swap after page load but the result seems to be different, any guidance please?
  • b

    bland-coat-6833

    09/01/2022, 9:56 AM
    This seems great in the example but I worry about what happens when you have more than one route. Looks like you'll end up with a lot of repetition? In python+Jinja land I use a pattern like this
    Copy code
    jinja
    {% if request.htmx %}{% extends 'layout.html %}{% endif %}
    {% block content %}
    <button type="button" class="button">A button</button>
    {% endblock %}
    Then I can render just the
    button
    if it's an htmx request. Otherwise I get the whole page back. Plus then any layout updates only need to happen in one file. Do I end up with a load of template fragments? Yep. Can't really see a way around that.
  • b

    bland-coat-6833

    09/01/2022, 10:40 AM
    Also: obviously the world needs another JavaScript framework but this one looks nice and seems like it could lend itself towards HTMX: https://enhance.dev/docs/ Server side rendering, html first, things like that. It's been done by the https://arc.codes team, so deploys nicely to AWS and begin.com.
  • m

    mysterious-toddler-20573

    09/01/2022, 1:03 PM
    depending on your impl, main advantage I can think of w/ labeled fragments is you can only render part of the template, rather than selecting content out of a template that's been rendered entirely
  • m

    mysterious-toddler-20573

    09/01/2022, 1:03 PM
    depends on your impl though
  • m

    mysterious-toddler-20573

    09/01/2022, 1:04 PM
    i can imagine many ways to select content out
  • m

    mysterious-toddler-20573

    09/01/2022, 1:05 PM
    why would template fragments have any effect on that? You could wrap the button (or any other content) in a fragment if you also wanted to render it in a different way, but it shouldn't have any effect on the normal rendering of that template
  • b

    bland-coat-6833

    09/01/2022, 1:07 PM
    Yeah - I think I'm missing something subtle.
  • m

    mysterious-toddler-20573

    09/01/2022, 1:11 PM
    🙂
  • m

    mysterious-toddler-20573

    09/01/2022, 1:11 PM
    template fragments are just a way to label a chunk of content in a template so you can render only that chunk, it shouldn't have any effect on the way the template works otherwise: it should be purely additive
  • b

    bland-coat-6833

    09/01/2022, 1:32 PM
    Yeah - so I think the example you gave was calling some
    render()
    function but then also giving it a fragment name. I think the jinja approach I've been doing is almost the reverse, it'll render just the fragment but expand out to the full page if it's not an htmx request (or whatever)
  • m

    mysterious-toddler-20573

    09/01/2022, 1:33 PM
    Right, and that works for the case when you want to flip on and off a layout
  • m

    mysterious-toddler-20573

    09/01/2022, 1:33 PM
    but sometimes you want to render multiple bits from within a larger template
  • m

    mysterious-toddler-20573

    09/01/2022, 1:33 PM
    e.g. if you have a polling + some button that dynamically updates another part of the DOM
  • m

    mysterious-toddler-20573

    09/01/2022, 1:34 PM
    so you can keep that code in there for toggling layouts, but also just render those two fragments
1...805806807...1146Latest