Hey there
I created two show more links on one page. That worked well so far. The first link works perfect. But when I click on the second button to enlarge or enroll, it automatically scrolls up to the top of the page, which makes no sense at all. Can anyone help? Thank you!
CODE
let fullTextOne; // variable to hold the full text
let shortTextOne; // variable to hold the short version of the text
let fullTextTwo; // variable to hold the full text
let shortTextTwo; // variable to hold the short version of the text
// how many characters to include in the shortened version
$w.onReady( function () {
const shortTextLengthOne = 668;
// read the full text and store it in the fullText variable
fullTextOne = $w(“#text7”).text;
// grab the number of characters defined in shortTextLength and store them in the shortText variable
shortTextOne = fullTextOne.substr(0, shortTextLengthOne);
// set the contents of the text element to be the short text
$w(“#text7”).text = shortTextOne;
//TODO: write your page related code here…
const shortTextLengthTwo = 617;
// read the full text and store it in the fullText variable
fullTextTwo = $w(“#text3”).text;
// grab the number of characters defined in shortTextLength and store them in the shortText variable
shortTextTwo = fullTextTwo.substr(0, shortTextLengthTwo);
// set the contents of the text element to be the short text
$w(“#text3”).text = shortTextTwo;
//TODO: write your page related code here…
});
export function button1_click(event, $w) {
// display the full text
// check the contents of the text element
if ($w(“#text7”).text === shortTextOne) {
// if currently displaying short text, display the full text
$w(“#text7”).text = fullTextOne;
$w(“#button1”).label = “weniger anzeigen”;
} else {
// if currently displaying full text, display the short text
$w(“#text7”).text = shortTextOne;
$w(“#button1”).label = “mehr lesen…”;
}
}
export function button5_click(event, $w) {
// display the full text
// check the contents of the text element
if ($w(“#text3”).text === shortTextTwo) {
// if currently displaying short text, display the full text
$w(“#text3”).text = fullTextTwo;
$w(“#button5”).label = “weniger anzeigen”;
} else {
// if currently displaying full text, display the short text
$w(“#text3”).text = shortTextTwo;
$w(“#button5”).label = “mehr lesen…”;
}
}