mysterious-toddler-20573
12/23/2021, 11:08 PMabundant-breakfast-94967
12/24/2021, 12:32 AMabundant-breakfast-94967
12/24/2021, 12:33 AMhx-post="/app/search/"
I guess I need to dynamially populate this string based on the form values, using JSmysterious-toddler-20573
12/24/2021, 12:51 AMmysterious-toddler-20573
12/24/2021, 12:52 AMmysterious-toddler-20573
12/24/2021, 12:52 AMabundant-breakfast-94967
12/24/2021, 12:53 AM<div
id="search-results"
class="hidden"
>abundant-breakfast-94967
12/24/2021, 12:55 AMx-data on the form which binds the form data. I also have a js expression that creates the URL from the selected items in the form. However, blocked on being able to use the resulting js expression in hx-postabundant-breakfast-94967
12/24/2021, 12:58 AMabundant-breakfast-94967
12/24/2021, 1:05 AMabundant-breakfast-94967
12/24/2021, 1:32 AMhx-push-url="true" this populated the URL in the browser with my crafted stringmost-flag-2080
12/24/2021, 5:24 AMblue-gold-89534
12/24/2021, 1:22 PMhtml
<button class="btn btn-primary btn-sm"
hx-get="{% url 'detail' product.pk %}"
hx-swap="outerHTML">
edit
</button>
There are multiple buttons, what would be the best way to prevent a user from swapping multiple forms at once? I want a click outside this row or on any other edit button to close the form right now and open the selected one.mysterious-toddler-20573
12/24/2021, 1:30 PMhtml
<button class="btn btn-primary btn-sm"
hx-swap="click[noOtherEditsOngoing]"
hx-get="{% url 'detail' product.pk %}"
hx-swap="outerHTML">
edit
</button>
and then manage the noOtherEditsOngoing state in the responses to the edit/update/cancel responsesmysterious-toddler-20573
12/24/2021, 1:47 PMfetch command will support both configurable timeouts as well as a really slick way to abort requests via a fetch:abort event:
html
<button id="btn1"
_="on click
add @disabled
fetch /whatever
put the result after me
finally
remove @disabled">
Get Response
</button>
<button _="on click send fetch:abort to #btn1">
Cancel The Request
</button>
this stacks up really well when compared w/ the javascript:
js
var controller = new AbortController();
var signal = controller.signal;
var downloadBtn = document.querySelector('.download');
var abortBtn = document.querySelector('.abort');
downloadBtn.addEventListener('click', fetchVideo);
abortBtn.addEventListener('click', function() {
controller.abort();
console.log('Download aborted');
});
function fetchVideo() {
...
fetch(url, {signal}).then(function(response) {
...
}).catch(function(e) {
reports.textContent = 'Download error: ' + e.message;
})
}
here it is in action, very pleased with how this turned out, and will likely integrate this 'event for request cancellation' idea into htmx as well.
Events (and async transparency) for the win!mysterious-toddler-20573
12/24/2021, 7:23 PMmysterious-branch-827
12/24/2021, 7:31 PMblue-gold-89534
12/24/2021, 10:35 PMblue-gold-89534
12/24/2021, 11:51 PMhx-swap in my button, which triggers on click: hx-swap="click[noOtherEditsongoing] - does this mean, I should put the logic that prevents a user to click another button in a js function?
var noOtherEditsongoing = function() { ... return true}
or am I completely off-track?mysterious-toddler-20573
12/25/2021, 12:54 AMmysterious-toddler-20573
12/25/2021, 12:54 AM<button> elements)mysterious-branch-827
12/25/2021, 8:24 AMadamant-exabyte-92636
12/25/2021, 8:26 AMadamant-exabyte-92636
12/25/2021, 9:38 AMmysterious-branch-827
12/25/2021, 9:39 AMadamant-exabyte-92636
12/25/2021, 9:41 AMrefined-waiter-90422
12/25/2021, 3:56 PMmysterious-toddler-20573
12/25/2021, 5:29 PMsalmon-oil-67352
12/25/2021, 10:27 PM