Question:
On my Editor X website i have a repeater. In the database, there is a fieldkey called “segmentType”. I would like to achieve the following: If “segmentType” = X, I would like container A to be collapsed and container B to be expanded. I am using the below code. What am I doing wrong?
$w.onReady(function () {
$w(‘#dayOneDataset’).onReady(() => {
$w(‘#repeater17’).onItemReady(($item, itemData) => {
if(itemData.segmentType) {
let segmentType = itemData.segmentType;
if ((segmentType == “TRANSPORTATION/FLIGHT”) || (segmentType == null) ||
(segmentType == undefined)) {
$item(“#day1staycontainer”).collapse(); //Handle case if segmentType is TRANSPORTATION/FLIGHT or does not have any value
} else {
$item(“#day1flightcontainer”).collapse();
$item(“#day1staycontainer”).collapse(); //Handle case if segmentType has some other value
}
} else {
$item(“#day1staycontainer”).collapse(); //Handle case if segmentType does not exist
}
});
});
});
Thanks so much for your suggested code! I cannot seem to get it right with your code. Maybe we can make the approach a little different to make the code easier; if I set the “day1flightcontainer” collapsed by default and just have the code expand it you’d say that it would be like this right:
$w.onReady(function () {
$w('#dayOneDataset').onReady(() => {
$w('#repeater17').onItemReady(($item, itemData) => {
if(itemData.segmentType) {
let segmentType = itemData.segmentType;
if (segmentType === "TRANSPORTATION/FLIGHT") {
$item('#day1flightcontainer').expand(); //Handle case if segmentType is TRANSPORTATION/FLIGHT or does not have any value
}
}
});
});
});```
Thanks, happy new year!!