Prevent HTMX from messing up the initial state
Django CI/CD / build-and-push (push) Successful in 1m15s
Details
Django CI/CD / build-and-push (push) Successful in 1m15s
Details
This commit is contained in:
parent
b7e14ecc83
commit
206b5f6d46
|
@ -29,3 +29,15 @@ document.addEventListener("htmx:afterSwap", setupElementHandlers);
|
|||
getEl("#id_type").onchange = () => {
|
||||
setupElementHandlers();
|
||||
};
|
||||
|
||||
document.body.addEventListener('htmx:beforeRequest', function(event) {
|
||||
// Assuming 'Purchase1' is the element that triggers the HTMX request
|
||||
if (event.target.id === 'id_edition') {
|
||||
var idEditionValue = document.getElementById('id_edition').value;
|
||||
|
||||
// Condition to check - replace this with your actual logic
|
||||
if (idEditionValue != '') {
|
||||
event.preventDefault(); // This cancels the HTMX request
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue