I am new to using Corvid on Wix and have been using the tutorials to try to create 3 expandable text boxes using ‘show more’ buttons. However, although I can get the text to be shortened with the ellipses - the only ‘show more’ button that works (button 14) displays the text from a different box (“text 23” not “text 19” as it should). So not sure what I am doing wrong?
You also need fullText and shortText specific to each text box or the different texts will overwrite.
gentle reminder: Please observe the Community Guidelines and post your code code, nicely formatted, in code blocks so that we can easily read the code.
Oh, sorry - wasn’t sure what a code block meant. When you say “fullText and shortText specific to each text box” is that not what I have done below?
$w.onReady(function () {
// how many characters to include in the shortened version
const shortTextLength = 40; // you can change this number
// read the full text and store it in the fullText variable
fullText = $w("#text17").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("#text17").text = shortText;
});
export function button13_click(event) {//make sure you have added the onClick event in properties
// check the contents of the text element
if ($w("#text17").text === shortText) {
// if currently displaying short text, display the full text
$w("#text17").text = fullText;
$w("#button13").label = "Show less";
} else {
// if currently displaying full text, display the short text
$w("#text17").text = shortText;
$w("#button13").label = "Show more";
}
}
Yes, but you stated that the text that gets displayed is from the wrong box. You wlll need fullText and shortText for each text box. Something like this:
let fullText1;
let fullText2;
let fullText3;
let shortText1;
let shortText2;
let shortText3;
In this way, each block of text is handled completely separately.
@yisrael-wix thanks - that seems to have solved it!
Sally, as Yisrael has mentioned about the Forum Guidelines, note that in there is a statement about searching the forum for previous posts on your issue.
Posting guidelines:
Search Before Posting. Use the Forum search. There's a great chance that someone has already solved the problem that you are facing. If you post a question that has already been asked and answered, your post may be locked. You might find the answer to your question by searching the Corvid documentation.
This show more/show less toggle and show button tutorial has been asked about in previous forum posts so many times that it could have it’s own forum section
It wouldn’t be too bad if it at least had a little statement somewhere about using it for multiple occurences and then it wouldn’t be asked so many time in this forum like here.
Anyways, glad it is sorted for you now.
@givemeawhisky Sorry about that - I honestly didn’t think there would be an issue with multiple versus single expandable boxes. Very new to Corvid and coding in general. Will double check next time.