I would like to use a button to reveal a text block on first click and hide it on second click. I have managed to make the text appear, but the second click makes the button – but not the text-- hide.
Do I need a separate event function to make it hide? Something else? Thanks in advance for helping me fix my broken code.
// Ed
let fullText1;
let shortText1;
// Aud
let fullText2;
let shortText2;
$w.onReady(function () {
//Ed
const shortText1Length = 0;
fullText1 = $w("#text22").text;
shortText1 = fullText1.substr(0, shortText1Length) + "";
$w("#text22").text = shortText1;
//Aud
const shortText2Length = 0;
fullText2 = $w("#text20").text;
shortText2 = fullText2.substr(0, shortText2Length) + "";
$w("#text20").text = shortText2;
});
//export functions here
//Ed
export function button1_click(event, $w) {
if ($w("#text22").text === shortText1) {
$w("#text22").text = fullText1;
$w("#button1").label = "Hide his bio";
} else {
$w("#text22").text = shortText1;
$w("#button1").label = "Read his bio";
}
if ($w("#text22").text === shortText1) {
$w("#text22").text = fullText1;
$w("#button1").collapse();
}}
//Aud
export function button2_click(event, $w) {
if ($w("#text20").text === shortText2) {
$w("#text20").text = fullText2;
$w("#button2").label = "Hide her bio";
} else {
$w("#text20").text = shortText2;
$w("#button2").label = "Read her bio";
}
if ($w("#text20").text === shortText2) {
$w("#text20").text = fullText2;
$w("#button2").collapse();
}}