I’ve been following a tutorial for creating a show more button which will help display text from a database into a text box to a certain amount/size and the rest will be hidden with the option for the user to click on a button saying “show more”:
https://support.wix.com/en/article/wix-code-tutorial-creating-a-show-more-link
I’ve got everything working but for some reason this is messing up two things:
- Making the text box now show with all the html coding as seen below instead of just text.
- Repeating the same entry rather then pulling all the data from the database and filling the repeater which it previously did.
This is the code I am currently using:
$w.onReady( function () {
$w(“#dataset1”).onReady( function () {
// how many characters to include in the shortened version
const shortTextLength = 350;
// set the fullText variable to be the text from the collection
fullText = $w(‘#dataset1’).getCurrentItem().jobDescription;
// if the text has fewer or the same number of characters as shortTextLength characters, display it as is and collapse the “Show More” button
if (fullText.length <= shortTextLength) {
$w(‘#repjobdesc’).text = fullText;
$w(‘#showmore’).collapse();
} else {
// create the shortened version of the text and display it in the text element
shortText = fullText.substr(0, shortTextLength) + “…”;
$w(‘#repjobdesc’).text = shortText;
}
});
the repjobdesc is my text element and showmore is my button.
Anyone have any idea what I’m doing wrong? Any help will be greatly appreciated.