Working in
Dev Mode
What I’m trying to do
I’m trying to use buttons to show specific sections that I have collapsed on the page. I’ve already coded the buttons to expand on their specific section when pressed but they don’t automatically switch to a different section when you click a different button.
Example of what the code does:
I press “iconbutton1”, it expands “section5”. I click “iconbutton2”, it expands “section4” but doesn’t collapse “section5”. I have to click “iconbutton1” one more time so that “section5” collapsed and I can see “section4”.
Here’s the code:
$w.onReady(function (){
let isExpanded = false;// Track the state of the section
$w(“#iconButton1”).onClick(() => {
if (isExpanded){
$w(“#section5”).collapse();
} else {
$w(“#section5”).expand();
}
isExpanded = !isExpanded; // Toggle the state
});
});
$w(‘#iconButton1’).onClick((event) => {
})
$w.onReady(function (){
let isExpanded = false;// Track the state of the section
$w(“#iconButton2”).onClick(() => {
if (isExpanded){
$w(“#section6”).collapse();
} else {
$w(“#section6”).expand();
}
isExpanded = !isExpanded; // Toggle the state
});
});
$w(‘#iconButton2’).onClick((event) => {
})
$w.onReady(function (){
let isExpanded = false;// Track the state of the section
$w(“#iconButton3”).onClick(() => {
if (isExpanded){
$w(“#section4”).collapse();
} else {
$w(“#section4”).expand();
}
isExpanded = !isExpanded; // Toggle the state
});
});
$w(‘#iconButton3’).onClick((event) => {
})