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

    astonishing-teacher-48635

    10/29/2022, 5:56 PM
    var promptQuestion = getClosestAttributeValue(elt, "hx-prompt"); if (promptQuestion) { var promptResponse = prompt(promptQuestion); // prompt returns null if cancelled and empty string if accepted with no entry if (promptResponse === null || !triggerEvent(elt, 'htmx:prompt', {prompt: promptResponse, target:target})) { maybeCall(resolve); endRequestLock(); return promise; } }`
  • a

    astonishing-teacher-48635

    10/29/2022, 5:57 PM
    guessing it then would have to be done as a custom hx attribute, is that supported?
  • a

    astonishing-teacher-48635

    10/29/2022, 6:01 PM
    seems I've hit a dead end, I think id need to PR htmx and add a htmx:beforePrompt and htmx:beforeConfirm to hook it properly
  • a

    astonishing-teacher-48635

    10/29/2022, 6:08 PM
    testing this theory
  • f

    freezing-waitress-26396

    10/29/2022, 6:17 PM
    @astonishing-teacher-48635 wrap text in single backticks ` to highlight single line code or multiple lines of code in three backticks ``` to make it more readable *`*single line*`* =
    single line
    *```*multi line with indentation*```* =
    Copy code
    multi
         line
             with indentation
  • a

    astonishing-teacher-48635

    10/29/2022, 6:31 PM
    was breaking the enter key, works with the edit
  • m

    mysterious-toddler-20573

    10/29/2022, 6:35 PM
    You can use a boost and set an hx-target. The default is
    body
    but you can target anything.
  • m

    mysterious-toddler-20573

    10/29/2022, 6:35 PM
    let me look if there's a spot to hook in
  • m

    mysterious-toddler-20573

    10/29/2022, 6:36 PM
    that won't make the code impossible(er) to understand
  • a

    astonishing-teacher-48635

    10/29/2022, 6:36 PM
    @mysterious-toddler-20573 i think the main issue is confirm() and prompt() are blocking
  • a

    astonishing-teacher-48635

    10/29/2022, 6:36 PM
    where as sweetalert is not
  • a

    astonishing-teacher-48635

    10/29/2022, 6:36 PM
    i was able to trigger a beforeConfirm and beforePrompt event and hook it in the extension properly
  • a

    astonishing-teacher-48635

    10/29/2022, 6:37 PM
    Copy code
    var confirmQuestion = getClosestAttributeValue(elt, "hx-confirm");
                if (confirmQuestion) {
                    if (!triggerEvent(elt, 'htmx:beforeConfirm', {confirm: confirmQuestion, target:target})) {
                        maybeCall(resolve);
                        endRequestLock()
                        return promise;
                    } else {
                        if(!confirm(confirmQuestion)) {
                            maybeCall(resolve);
                            endRequestLock()
                            return promise;
                        }                                        
                    }
                }
  • m

    mysterious-toddler-20573

    10/29/2022, 6:38 PM
    yep
  • m

    mysterious-toddler-20573

    10/29/2022, 6:38 PM
    we need a way to make this async-friendly
  • a

    astonishing-teacher-48635

    10/29/2022, 6:38 PM
    yup
  • m

    mysterious-toddler-20573

    10/29/2022, 6:38 PM
    I'd like to find an existing callback so we don't have to add more
  • m

    mysterious-toddler-20573

    10/29/2022, 6:38 PM
    where we can hook this in
  • m

    mysterious-toddler-20573

    10/29/2022, 6:39 PM
    looking at the trigger spec now
  • m

    mysterious-toddler-20573

    10/29/2022, 6:39 PM
    many an event there where you can re-wire the handler somehow to go through your own code
  • a

    astonishing-teacher-48635

    10/29/2022, 6:42 PM
    is it possible to create custom hx- attributes?
  • m

    mysterious-toddler-20573

    10/29/2022, 6:42 PM
    you can
  • m

    mysterious-toddler-20573

    10/29/2022, 6:42 PM
    but you need the right shape of events to do this right
  • a

    astonishing-teacher-48635

    10/29/2022, 6:43 PM
    so i could do soemthing like
    Copy code
    <button hx-ext="htmx-swal" hx-post="/q" hx-swal-confirm="do you accept?">
  • m

    mysterious-toddler-20573

    10/29/2022, 6:43 PM
    Yeah, man, this is america jack, you can do whatever you want.
  • m

    mysterious-toddler-20573

    10/29/2022, 6:43 PM
    However, as this is america, it will usually not work right.
  • m

    mysterious-toddler-20573

    10/29/2022, 6:43 PM
    we need a place where async can work w/o needing to completely rework the code.
  • m

    mysterious-toddler-20573

    10/29/2022, 6:43 PM
    I'm thinking.
  • g

    green-activity-6102

    10/29/2022, 6:47 PM
    thats interesting... what's the use case for that?
  • m

    mysterious-toddler-20573

    10/29/2022, 6:51 PM
    If you want all your links to replace
    <main/>
    , for example
1...881882883...1146Latest