I followed this very helpful tutorial (link below) to create a show-more/less functionality on my website. For the most part, it’s worked great! The only issue I’ve run into is that regardless of how I have formatted the text in the text editor, the text in the text box reverts back to its original uniform formatting (all one color, all one size, nothing bolded or italicized) in both the short text and full text versions. I’d love retain the formatting distinctions I’ve made in the text editor and the functionality of the show-more/less button. How can I have my cake and eat it too? Help me Corvid Forum, you are my only hope!
It’s not easy to explain how to use the html since it needs to be tailored to the specific text and format.
So instead of that, let me suggest a shortcut:
Have 2 different texts-boxes
In textbox1 put your full text, set it to be collapsed by default.
In textbox2 put your short text. Set it to be expanded by default.
Then use a condition to expand and collapse the relevant text-boxes.
Thank you for the tip JD. It isn’t clear to me how the page display just one text box at a time, but after I put the code in, perhaps that will be more apparent.
Well, shoot. This occurs to me. The text is in a repeater and we will have articles of different length. Does the full text box actually have to be large enough on the page to accommodate the full text? If so, we’ll have blank space between articles because I’ll have to put a long box in for long articles that won’t be filled by shorter articles.
@jonatandor35 Ok. Makes sense. However, I have the code in and it’s showing the expanded version. It’s also showing it in white. I think that’s a rich text issue and have gone back several times to reformat it. But, I put the text boxes in backwards the first time. It showed the full text with a Show More button. I reversed the box names in the code and still get the full text with a show more button.
This is the code. #text26 is the short text. #text28 is the full version.
$w(“#button3”).onClick((event) => { if ($w(“#text28”).collapsed){
$w(“#button3”).label = “Show less”;
$w(“#text26”).collapse();
$w(“#text28”).expand();
} else {
$w(“#button3”).label = “Show More”;
$w(“#text28”).collapse();
$w(“#text26”).expand();
}
})
@jonatandor35 When I go back and look at your original instructions just above the code, I see that the code should be in that onReady(). How should that line of code read. My page is missing it.