salmon-church-58191
10/27/2022, 5:40 AMsalmon-church-58191
10/27/2022, 5:41 AMboundless-leather-51644
10/27/2022, 6:36 AMbrainy-ice-92385
10/27/2022, 6:46 AMboundless-leather-51644
10/27/2022, 7:32 AM<form class="form-horizontal" action="/claim" hx-post="/claim" hx-target="#response" method="POST" hx-swap="innerHTML">
--> content returned to HTMX: <div class=\"alert alert-success\">Claim created successfully for id: " + claim.id + "</div>"
--> content displayed within the <div id=response>
--> Button is not disabled using such JS function!!
(() => {
// EventListener watching submit button event
// If the class of element includes "alert-success", then disable the button
// Clean the inner HTML of the <div id="response"> to remove previously displayed messages
document.addEventListener("submit", () => {
const msg = document.querySelectorAll("alert-success").forEach((item) => {
document.getElementById("claim-button").setAttribute("disabled",true);
});
document.getElementById("response").innerHTML = "";
});
})();
boundless-leather-51644
10/27/2022, 9:58 AMhtmx.on
function đ
// Event watching when HTMX is swapping the HTML content
// If the div tag includes as class "alert-success",, then the button is disabled
htmx.on("htmx:afterSwap",function(evt) {
const msg = evt.detail.elt.outerHTML;
if (msg.includes("alert-success")) {
document.getElementById("claim-button").setAttribute("disabled", true);
};
});
fancy-train-23639
10/27/2022, 12:43 PMdiv
, but somehow it ended up cutting more (The td
elements. In the end I went with an event to get the row updated which I think is more elegant, but I was wondering if this was a bug.fancy-train-23639
10/27/2022, 12:44 PMtd
level, which made me wonder if this was some kind of bug. No big deal for me, I went with a different approach, but was wondering if it was worth reporting.boundless-vase-80440
10/27/2022, 1:23 PMmysterious-toddler-20573
10/27/2022, 1:24 PMmysterious-toddler-20573
10/27/2022, 1:25 PMhtmx.config.useTemplateFragments
to true to see if template-style parsing fixes the issuemysterious-toddler-20573
10/27/2022, 1:25 PMgreen-activity-6102
10/27/2022, 2:27 PMfancy-train-23639
10/27/2022, 2:35 PMfancy-train-23639
10/27/2022, 2:36 PMmysterious-toddler-20573
10/27/2022, 2:38 PMgreen-activity-6102
10/27/2022, 2:51 PMmysterious-toddler-20573
10/27/2022, 2:53 PMgreen-activity-6102
10/27/2022, 2:55 PMmysterious-toddler-20573
10/27/2022, 2:56 PMboundless-vase-80440
10/27/2022, 3:01 PMfancy-train-23639
10/27/2022, 3:02 PMmysterious-toddler-20573
10/27/2022, 3:17 PMminiature-lizard-24702
10/27/2022, 4:15 PMmysterious-toddler-20573
10/27/2022, 4:30 PMminiature-lizard-24702
10/27/2022, 6:39 PMmysterious-toddler-20573
10/27/2022, 7:00 PMminiature-lizard-24702
10/27/2022, 7:27 PMminiature-lizard-24702
10/27/2022, 7:27 PMgreen-flower-49070
10/27/2022, 9:38 PM