Dear All,
I have a repeater with 4 dropdowns connected to a collection.
On page load, I would like to put a green background for each dropdown filled out onto the repeater.
With my following code, it is not working.
$w.onReady(function () {
$w("#Repeater").onItemReady(($item, itemData, index) => {
//SUB-CATEGORIES
if ($item("#DropdownSubCategory1").selectedIndex >= 0) {
($item("#DropdownSubCategory1").style.backgroundColor = "#B1D3BB");
($item("#DropdownSubCategory1").style.borderColor = "#B1D3BB");
}
if ($item("#DropdownSubCategory2").selectedIndex >= 0) {
($item("#DropdownSubCategory2").style.backgroundColor = "#B1D3BB")
($item("#DropdownSubCategory2").style.borderColor = "#B1D3BB")
}
if ($item("#DropdownSubCategory3").selectedIndex >= 0) {
($item("#DropdownSubCategory3").style.backgroundColor = "#B1D3BB");
($item("#DropdownSubCategory3").style.borderColor = "#B1D3BB");
}
if ($item("#DropdownSubCategory4").selectedIndex >= 0) {
($item("#DropdownSubCategory4").style.backgroundColor = "#B1D3BB");
($item("#DropdownSubCategory4").style.borderColor = "#B1D3BB");
}
});
});
but if I add “setTimeout(function () {“ for each dropdown, it works.
$w.onReady(function () {
$w("#Repeater").onItemReady(($item, itemData, index) => {
//SUB-CATEGORIES
setTimeout(function () {
if ($item("#DropdownSubCategory1").selectedIndex >= 0) {
($item("#DropdownSubCategory1").style.backgroundColor = "#B1D3BB");
($item("#DropdownSubCategory1").style.borderColor = "#B1D3BB");
}
}, 1000)
setTimeout(function () {
if ($item("#DropdownSubCategory2").selectedIndex >= 0) {
($item("#DropdownSubCategory2").style.backgroundColor = "#B1D3BB")
($item("#DropdownSubCategory2").style.borderColor = "#B1D3BB")
}
}, 1000)
setTimeout(function () {
if ($item("#DropdownSubCategory3").selectedIndex >= 0) {
($item("#DropdownSubCategory3").style.backgroundColor = "#B1D3BB");
($item("#DropdownSubCategory3").style.borderColor = "#B1D3BB");
}
}, 1000)
setTimeout(function () {
if ($item("#DropdownSubCategory4").selectedIndex >= 0) {
($item("#DropdownSubCategory4").style.backgroundColor = "#B1D3BB");
($item("#DropdownSubCategory4").style.borderColor = "#B1D3BB");
}
}, 1000)
});
});
Is my second code correct or is there another way to retype it?
Thank you for your help.
Best regards,
Domivax