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

    ripe-action-67367

    09/06/2022, 6:22 PM
    keyup[target.value.length > 2]
  • r

    ripe-action-67367

    09/06/2022, 6:22 PM
    or something like that
  • p

    proud-librarian-99598

    09/06/2022, 6:32 PM
    Thanks, that works perfectly!
  • p

    proud-librarian-99598

    09/06/2022, 6:33 PM
    The drawback I see now is that if you type something in the search box and then remove it again, there is no call to the backend (obviously), so the old search results remain in place.
  • m

    miniature-lizard-24702

    09/06/2022, 6:37 PM
    😅
  • m

    mysterious-toddler-20573

    09/06/2022, 7:22 PM
    you could use an
    ||
    with a backspace key filter as well
  • r

    rhythmic-shoe-62185

    09/06/2022, 10:12 PM
    made a demo of your template fragments essay in my new project (code named Pushup, not quite yet released) - https://pushup-htmx-template-fragments.fly.dev/demo (it works, click the button and watch the network requests in dev tools) we call template fragments "inline partials" in Pushup, but the concept is the same. you can see the source of the template markup here: https://pushup-htmx-template-fragments.fly.dev/view-source?route=/demo what's (possibly) interesting/different about template fragments in Pushup is they participate in the URL routing: if the page is at
    /foo
    and it has an inline partial named
    bar
    , then the contents of the partial independently, minus the surrounding page, can be requested at
    /foo/bar
    . still early in the design phase, but roughly am happy with how they are evolving.
  • m

    mysterious-toddler-20573

    09/06/2022, 11:43 PM
    Can you pr my essay with a link?
  • a

    ancient-father-3063

    09/07/2022, 1:17 AM
    I'm having trouble understanding HX-Trigger Response Headers
  • a

    ancient-father-3063

    09/07/2022, 1:17 AM
    Copy code
    <div hx-trigger="myEvent from:body" hx-get="/example"></div>
    When/How is this event triggered?
  • a

    ancient-father-3063

    09/07/2022, 1:21 AM
    Copy code
    html
      <input class="form-check-input" type="checkbox" name="checkbox" value="8" id="testtrigger" hx-trigger="myEvent">
      <label class="form-check-label" for="filteractivedecks"><small>test trigger</small> </label> 
      <div hx-trigger="myEvent from:body" hx-get="/example"></div>
  • a

    ancient-father-3063

    09/07/2022, 1:21 AM
    I tried something like this, but no good
  • m

    mysterious-toddler-20573

    09/07/2022, 1:23 AM
    are you setting a response header
    HX-Trigger
    ?
  • a

    ancient-father-3063

    09/07/2022, 1:23 AM
    well I'm trying to learn what that is
  • a

    ancient-father-3063

    09/07/2022, 1:24 AM
    I'm afraid this is one of those things where I don't know the basics, if you don't mind explaining what a response header is
  • a

    ancient-father-3063

    09/07/2022, 1:25 AM
    or I mean, how to use it here
  • a

    ancient-father-3063

    09/07/2022, 2:05 AM
    ok sorry, but real question now
  • a

    ancient-father-3063

    09/07/2022, 2:06 AM
    I have two hx-triggers but I care what order they work in
  • a

    ancient-father-3063

    09/07/2022, 2:06 AM
    I need the first one to resolve first because the second one includes values from the first one
  • a

    ancient-father-3063

    09/07/2022, 2:06 AM
    what's the best way to do this?
  • d

    dry-pharmacist-51808

    09/07/2022, 2:25 AM
    Thanks! This seems a slight amount more branching logic serverside but seems best suited for experience. This Is your pager just included in #results then and not an oob update? That would make a good deal of sense
  • a

    ancient-father-3063

    09/07/2022, 2:27 AM
    I don't understand how to use 'after settle'
  • a

    ancient-father-3063

    09/07/2022, 2:27 AM
    I tried using hx-trigger queue:first/last but that didn't work either
  • a

    ancient-father-3063

    09/07/2022, 2:28 AM
    I put a delay of 500ms on the one I want to trigger last, and that does work
  • a

    ancient-father-3063

    09/07/2022, 2:29 AM
    I'm not sure why the queue first/last aren't working, that sounds like exactly what I need. They must not be in the same queue, even though they are triggering from the same event. I must be doing something wrong with that.
  • h

    hundreds-dusk-97323

    09/07/2022, 7:16 AM
    Hello everyone... I'm a new htmx user. is it possible open modal, and use click-to-edit and after save then restore modal body with saved data?
  • h

    hundreds-dusk-97323

    09/07/2022, 7:16 AM
    and this without close modal ?
  • r

    ripe-action-67367

    09/07/2022, 7:27 AM
    yes, it should absolutely be possible. Specifics depend on you implementation of modals, but generally you just need to return correct fragments from the server and set hx-target to your modal content element
  • h

    hundreds-dusk-97323

    09/07/2022, 7:41 AM
    ok you know somewhere examples i open modal this
    Copy code
    <button
                hx-get="ajax/testi.php"
                hx-target="#modals-here"
                hx-trigger="click"
                class="btn btn-primary"
                _="on htmx:afterOnLoad wait 10ms then add .show to #modal then add .show to #modal-backdrop">Open Modal</button>
    Copy code
    <div id="modal-backdrop" class="modal-backdrop fade show" style="display:block;"></div>
    <div id="modal" class="modal fade show" tabindex="-1" style="display:block;">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">Modal title</h5>
                </div>
                <div class="modal-body">
                    <p>Modal body text goes here.</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" onclick="closeModal()">Close</button>
                    <button type="button" class="btn btn-secondary" hx-get="ajax/testi.php">Save</button>
                </div>
            </div>
        </div>
    </div>
    this save button open new modal.. can this something return only modal content current open modal
  • s

    stocky-dentist-80693

    09/07/2022, 9:22 AM
    @dry-pharmacist-51808 Yes, table + pager are together in the view template, no OOB swaps. The initial page AND htmx requests hit the same route and respond with the same view - header, main content area, footer, etc. It's the
    hx-select
    and
    hx-target
    that do the magic. I could add some other logic to be more selective to only render the table + pager, but it's slightly more effort for little gain in this instance.
    Copy code
    php
    // ... (other page stuff like title)
    //
    
    $search = form_input([
        'type' => 'search',
        'class' => 'pure-input-rounded w-100 pure-input-light',
        'id' => 'search',
        'name' => 'search',
        'placeholder' => 'Search...',
        'hx-get' => current_url(),
        'hx-trigger' => 'keyup changed delay:75ms, search',
        'hx-target' => '#results',
        'hx-select' => '#results',
        'value' => esc($filter->search ?? ''),
    ]);
    echo "<div class='pure-form mb-md'>{$search}</div>";
    
    echo "<div id='results'>";
    echo $table->render(true);
    echo $pager->links();
    echo "</div>";
1...819820821...1146Latest