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

    helpful-secretary-3515

    12/18/2020, 1:13 AM
    is this the JS Code (or some of it) that needs to be loaded? document.addEventListener('DOMContentLoaded', function () { window.demo = new Demo(document.getElementById('grid')); });
  • h

    helpful-secretary-3515

    12/18/2020, 1:13 AM
    when i follow https://htmx.org/docs/#events : i see this: htmx.on("htmx:load", function(evt) { myJavascriptLib.init(evt.details.elt); });
  • g

    gorgeous-ghost-95789

    12/18/2020, 1:24 AM
    @mysterious-toddler-20573, if you want to make a Christmas wish list of tutorials and examples (on GitHub, maybe) I’ll take a crack at as many as I can. How do you feel about publishing some sample code on CodePen?
  • g

    gorgeous-ghost-95789

    12/18/2020, 1:25 AM
    It will give you more time to review my PRs, and keep me from going rogue and posting more PRs. 😇
  • m

    mysterious-toddler-20573

    12/18/2020, 1:33 AM
    yes, the next example below that
  • m

    mysterious-toddler-20573

    12/18/2020, 1:33 AM
    which is a nicer way to accomplish the sam thing
  • m

    mysterious-toddler-20573

    12/18/2020, 1:34 AM
    Yeah, you are probably going to want something like this:
    Copy code
    js
      htmx.onLoad(function(target) {
        window.demo = new Demo(target.getElementById('grid'));  });
  • m

    mysterious-toddler-20573

    12/18/2020, 1:34 AM
    Although I can't be sure, since I don't know what Demo is
  • m

    mysterious-toddler-20573

    12/18/2020, 1:34 AM
    But it looks like you are going to want to initialize it when any new content is brought into the DOM by htmx
  • m

    mysterious-toddler-20573

    12/18/2020, 1:35 AM
    @User a good demo of this pattern, where someone is using a third party JS library that needs to be initialized on content loading, would be great
  • g

    gorgeous-ghost-95789

    12/18/2020, 1:36 AM
    Yes sir. And, any more that come to mind, send them my way.
  • m

    mysterious-toddler-20573

    12/18/2020, 1:36 AM
    thank you!
  • u

    user

    12/18/2020, 9:16 AM
    Hello! I've started using htmx and really like it, but I have a problem using the
    remove-me
    extension. I don't get it to work, not even with the simplest example. What I'm doing wrong here:
    Copy code
    <!DOCTYPE html>
    <html>
    <head>
        <title>htmx test</title>
    </head>
    <body>
        <script src="https://unpkg.com/htmx.org@1.0.2"></script>
        <script src="https://unpkg.com/htmx.org@1.0.2/dist/ext/remove-me.js"></script>
        <div hx-ext="remove-me">
            <div remove-me="1s">To Be Removed...</div>
        </div> 
    
    </body>
    </html>
    Maybe someone can enlighten me. Thank you.
  • t

    tall-dinner-62086

    12/18/2020, 9:48 AM
    @User Just testing this a bit, it seems to only work if you manually process the node after loading the page. Even processing the body node doesn't work, I'm having to manually find the div and call
    htmx.process()
    on it.
  • t

    tall-dinner-62086

    12/18/2020, 10:00 AM
    @User I managed to make it work by adding the extension to the body element instead of the parent div. On load, htmx only emits the
    processedNode
    event for the body node.
  • t

    tall-dinner-62086

    12/18/2020, 10:01 AM
    This should only be necessary if you have something you want to remove on the initial load, rather than content that you load in through htmx.
  • u

    user

    12/18/2020, 10:06 AM
    Thank you very much for your help and for clarification.
  • m

    mysterious-toddler-20573

    12/18/2020, 3:38 PM
    @User @User thank you for figuring that out. That seems like a bug in the extension, would you mind opening a github issue?
  • t

    tall-dinner-62086

    12/18/2020, 6:14 PM
    Is it a bug though? Should the extension try to dig into an element that didn't define it's using the extension when it's processed?
  • m

    mysterious-toddler-20573

    12/18/2020, 6:16 PM
    hmm
  • m

    mysterious-toddler-20573

    12/18/2020, 6:17 PM
    well, it seems like you should be able to use extensions ootb like this to me, so I think it is a bug... somewhere
  • m

    mysterious-toddler-20573

    12/18/2020, 6:17 PM
    not totally clear where though
  • t

    tall-dinner-62086

    12/18/2020, 6:20 PM
    Any extension that is depending on the
    processedNode
    event is probably behaving the same way
  • t

    tall-dinner-62086

    12/18/2020, 6:24 PM
    Which, apparently, is just that one and
    class-tools
  • t

    tall-dinner-62086

    12/18/2020, 6:25 PM
    It looks like benpate has a related PR on this
  • g

    gorgeous-ghost-95789

    12/18/2020, 6:27 PM
    If you're referencing https://github.com/bigskysoftware/htmx/pull/267 then I don't think that addresses this issue.
  • g

    gorgeous-ghost-95789

    12/18/2020, 6:28 PM
    That was just to make a new "init" that we could listen to, not to fix any issues with processedNode. 😦
  • b

    big-airline-13935

    12/18/2020, 8:10 PM
    htmx gets a mention alongside Sprig in this Craft CMS year in review: https://craftcms.com/blog/2020
  • m

    mysterious-toddler-20573

    12/18/2020, 9:07 PM
    Nice!
  • h

    helpful-secretary-3515

    12/19/2020, 8:20 PM
    i want to swap, after the user is clicking / visiting a modal.
1...103104105...1146Latest