Prevent HTMX from messing up the initial state
This commit is contained in:
parent
a32d6c38ab
commit
0f5067d66d
|
@ -29,3 +29,15 @@ document.addEventListener("htmx:afterSwap", setupElementHandlers);
|
||||||
getEl("#id_type").onchange = () => {
|
getEl("#id_type").onchange = () => {
|
||||||
setupElementHandlers();
|
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