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

    mysterious-toddler-20573

    09/06/2020, 12:49 AM
    attribute twizzling/detwizzling broken out on the right
  • u

    user

    09/07/2020, 3:07 PM
    Copy code
    <form class="form" data-hx-post="//sub.test.local/1/fetch" data-hx-target="#target" data-hx-swap="innerHTML">[...]</form>
    - trying to do hx-post to my endpoint, but in FF dev console there is OPTIONS request fired, and then the POST request blocked. What am I doing wrong?
  • u

    user

    09/07/2020, 3:07 PM
    Without htmx, usual action+method=POST working just fine... For what do OPTIONS request is firing?
  • u

    user

    09/07/2020, 3:09 PM
    https://stackoverflow.com/questions/1256593/why-am-i-getting-an-options-request-instead-of-a-get-request I think this is the answer to my question, and is not related to htmx itself, but still somewhat ugh...
  • m

    mysterious-toddler-20573

    09/07/2020, 3:12 PM
    is this cross domain?
  • n

    narrow-chef-14221

    09/07/2020, 3:18 PM
    Is there a way to "inverse" the fragment swapping? Let me explain. Normally htmx will fetch an html, select a section from it, and replace a portion of the current document with it. That's fine. But I need to replace many fragments from the page with updated data, and it'd be easier to tell htmx to replace the whole body BUT keep a specific section from the currently loaded HTML (I have a form there which the user might've entered something and I don't want to lose it). Is it possible?
  • n

    narrow-chef-14221

    09/07/2020, 3:19 PM
    If that's not possible... then I guess I'll need to send many
    hx-swap-oob
    sections in the response
  • u

    user

    09/07/2020, 3:43 PM
    > is this cross domain? @User Yeah, worked this out. I have two different servers, but was not familiar enough with CORS. Figured out I need to modify my apache conf files (or .htaccess) and add the needed stuff like
    Copy code
    Header set Access-Control-Allow-Headers "hx-active-element,hx-current-url,hx-request,hx-target"
        Header set Access-Control-Allow-Methods "POST"
  • u

    user

    09/07/2020, 3:43 PM
    Plus an origin of my requesting server... I hope I'm doing it right xD
  • m

    mysterious-toddler-20573

    09/07/2020, 3:43 PM
    welcome to web programming, enjoy your stay
  • u

    user

    09/07/2020, 3:43 PM
    Headache is here to stay, yeah xD
  • m

    most-jelly-15242

    09/07/2020, 4:21 PM
    In the docs https://htmx.org/events/, it says "If the event is cancelled, no request will occur.". How does one cancel an event?
  • g

    gorgeous-ghost-95789

    09/07/2020, 4:37 PM
    @narrow-chef-14221 -- I don't know of anything in HTMX that's an "inverse" of swapping a fragment. You might try isolating the part of your document that you want to keep, by putting it outside of that part that gets swapped. I'm thinking of global navigation (or something similar) that wouldn't be updated if you just swap a somewhere else within it.
  • g

    gorgeous-ghost-95789

    09/07/2020, 4:38 PM
    Obviously, this depends on your document structure, so it might not work for you.
  • w

    wooden-wall-85896

    09/07/2020, 5:14 PM
    🎙 devMode podcast episode 86: "Dynamic HTML with htmx" is out! 💪 https://devmode.fm/episodes/dynamic-html-with-htmx
  • m

    mysterious-toddler-20573

    09/07/2020, 5:20 PM
    @User you can cancel it by listening for the event and calling
    preventDefault()
  • m

    mysterious-toddler-20573

    09/08/2020, 12:05 AM
    event names:
  • m

    mysterious-toddler-20573

    09/08/2020, 12:06 AM
    option 1 - a configuration variable that allows you use use kebab naming rather than camel case option 2 - just switch to kebab naming option 3 - dispatch both camel and kebab named events
  • b

    big-airline-13935

    09/08/2020, 10:26 AM
    My vote is for option 2️⃣ (KISS)
  • u

    user

    09/08/2020, 10:34 AM
    Hey @User fancy seeing you here–regarding the ticket I opened with you https://github.com/putyourlightson/craft-sprig/issues/25 I decided to jump on here
  • u

    user

    09/08/2020, 10:34 AM
    So I've moved to using events which actually is a smarter way of doing what I'm after anyway
  • u

    user

    09/08/2020, 10:35 AM
    However I can't seem to get the component variables in refresh
  • u

    user

    09/08/2020, 10:37 AM
    though I'm not sure if it's a sprig question or a htmx question..
  • b

    big-airline-13935

    09/08/2020, 12:20 PM
    Well this is a htmx chat room @User 🙂
  • m

    mysterious-toddler-20573

    09/08/2020, 2:43 PM
    > However I can't seem to get the component variables in refresh @User can you explain this?
  • b

    big-airline-13935

    09/08/2020, 2:54 PM
    This sounds pretty Sprig specific.
  • a

    ancient-soccer-8576

    09/08/2020, 3:23 PM
    Hello, I changed the search example like this, but i get a htmx:targetError Search Tasks Searching... any idea?
  • u

    user

    09/08/2020, 3:34 PM
    Your target is
    results-tasks
    but your div is `results-task`–missing the s on tasks
  • a

    ancient-soccer-8576

    09/08/2020, 3:36 PM
    Oh well thank you this was driving me crazy, it was so simple! 👍
  • m

    mysterious-toddler-20573

    09/08/2020, 3:44 PM
    This is actually something that I have to say is hard about declarative programming in general: when stuff works it's great, but when it is going wrong it can be very hard to understand why. Need to think about how to handle that better.
1...242526...1146Latest