Fix broken FQDN due to timing problems
This commit is contained in:
parent
cce071397c
commit
5cee0194f5
1 changed files with 16 additions and 7 deletions
|
|
@ -9,7 +9,12 @@ const initializeFqdnGeneration = (prefix) => {
|
||||||
let isArrayField = true;
|
let isArrayField = true;
|
||||||
|
|
||||||
if (fqdnFieldContainer) {
|
if (fqdnFieldContainer) {
|
||||||
let fqdnField = fqdnFieldContainer.querySelector('input.array-item-input');
|
fqdnField = fqdnFieldContainer.querySelector("input.array-item-input")
|
||||||
|
if (!fqdnField) {
|
||||||
|
// We retry, as there is a field meant to be here, but not rendered yet
|
||||||
|
setTimeout(() => {initializeFqdnGeneration(prefix)}, 200)
|
||||||
|
return
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
fqdnField = document.getElementById(`id_${prefix}-spec.parameters.service.fqdn`);
|
fqdnField = document.getElementById(`id_${prefix}-spec.parameters.service.fqdn`);
|
||||||
isArrayField = false;
|
isArrayField = false;
|
||||||
|
|
@ -53,10 +58,14 @@ const initializeFqdnGeneration = (prefix) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {initializeFqdnGeneration("custom"), initializeFqdnGeneration("expert")});
|
const runFqdnInit = () => {
|
||||||
document.body.addEventListener('htmx:afterSwap', function(event) {
|
|
||||||
if (event.detail.target.id === 'service-form') {
|
|
||||||
initializeFqdnGeneration("custom");
|
initializeFqdnGeneration("custom");
|
||||||
initializeFqdnGeneration("expert");
|
initializeFqdnGeneration("expert");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
runFqdnInit()
|
||||||
|
});
|
||||||
|
document.body.addEventListener('htmx:afterSwap', function(event) {
|
||||||
|
if (event.detail.target.id === 'service-form') runFqdnInit()
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue