I am using below code to show / highlight an item on repeater. It’s a quiz page and explanation should be visible using below line once user click on “Show Answer” button. This is working fine in Preview mode however not working after publishing the site. I tried with box element as well and that’s also having same issue.
You can see the live page here . The explanation should be visible below “Show Answer” button.
Line number 5:
$item("#textanswer").show(); //this is working in preview mode only
Other code with in Switch statement is working fine in both preview and live mode.
export function buttonshowanswer_click(event) {
const itemClicked = event.context.itemId;
$w("#repeater1").forEachItem( ($item, itemData, index) => {
if (itemData._id === itemClicked) {
$item("#textanswer").show(); //This line does not work
let choice = ($item("#textcorrectchoice").text)
// console.log(choice)
switch (choice) {
case "A":
$item('#boxA').style.backgroundColor = "rgba(0,255,0,0.5)"
break;
case "B":
$item('#boxB').style.backgroundColor = "rgba(0,255,0,0.5)"
break;
case "C":
$item('#boxC').style.backgroundColor = "rgba(0,255,0,0.5)"
break;
case "D":
$item('#boxD').style.backgroundColor = "rgba(0,255,0,0.5)"
break;
default:
break;
}
}
});
}