I see that lots of previous posts present the same issue, but none have lead me to solve my own version it. I obviously have a missing or misplaced bracket or paren, but no matter what I add or change, it just relocates the error. Any debugging help for this novice is super appreciated. Thanks so much for your time. Cheers and best regards. -Scott
$w.onReady(function () {
$w("#button2").onClick((event) => {
if ($w("#text31").collapsed) {
$w("#button2").label = "Show Less Info";
$w("#text31").expand();
$w("#text44").expand();
} else {
$w("#button2").label = "Show More Info";
$w("#text31").collapse();
$w("#text44").collapse();
}
$w("#button3").onClick((event) => {
if ($w("#table1").collapsed) {
$w("#button3").label = "Show All Categories";
$w("#table2").expand();
$w("#table1").collapse();
} else {
$w("#button3").label = "Show Fewer Categories";
$w("#table1").expand();
$w("#table2").collapse();
}
// TODO: write your page related code here...
})
});
Hi Scott,
Yes, you forgot to add }) to the end of your code. You also need to move the:
$w("#button3").onClick((event) => {
}
out of:
$w("#button2").onClick((event) => {
}
Because there is an error message saying: ‘event’ is already declared in the upper scope. This means, you can’t have an event inside another event.
So, here is what your code should look like:
$w.onReady(function () {
$w("#button2").onClick((event) => {
if ($w("#text31").collapsed) {
$w("#button2").label = "Show Less Info";
$w("#text31").expand();
$w("#text44").expand();
} else {
$w("#button2").label = "Show More Info";
$w("#text31").collapse();
$w("#text44").collapse();
}
})
$w("#button3").onClick((event) => {
if ($w("#table1").collapsed) {
$w("#button3").label = "Show All Categories";
$w("#table2").expand();
$w("#table1").collapse();
} else {
$w("#button3").label = "Show Fewer Categories";
$w("#table1").expand();
$w("#table2").collapse();
}
// TODO: write your page related code here...
})
});
I hope this helps you. I tried it out to see if it works & it does.
Arthur
Wahoo! Perfect, Arthur! Can’t thank you enough for taking the time to help out a struggling beginner. All seems to be working as envisioned now. Have an awesome day.