I have a page with several long texts and toggle buttons.
My problem is that due to my text lengths, the buttons started to appear really far away from the shortened text that is actually displayed on the page before using the button, and I have no idea how to fix it. Just some of the buttons are like that, other ones are fine but they’re also not exactly where they should be. I want them to be at the end of the shortened text instead of appearing at the end of the long text, if that makes sense. I’m not sure if it’s an issue with the code, but here is a section of one of the texts that got messed up:
let fullText; // variable to hold the full text
let shortText; // variable to hold the short version of the text
$w.onReady( function () {
// how many characters to include in the shortened version
const shortTextLength = 90;
// read the full text and store it in the fullText variable
fullText = $w(“#text26”).text;
// grab the number of characters defined in shortTextLength and store them in the shortText variable
shortText = fullText.substr(0, shortTextLength) + “…”;
// set the contents of the text element to be the short text
$w(“#text26”).text = shortText;
});
export function button1_click(event) {
if ($w(“#text26”).text === shortText) {
// if currently displaying short text, display the full text
$w(“#text26”).text = fullText;
$w(“#button1”).label = “Show less”;
} else {
// if currently displaying full text, display the short text
$w(“#text26”).text = shortText;
$w(“#button1”).label = “Show more”;
}
}
Does anyone have the same problem?
Thanks in advance.