Dear Friends while i inserted the text code below
in text it is first showing all the text then after clicking the button it is showing less but i need the opposite,First it should less then after clicking read ore button it should show all kindly help.
// For full API documentation, including code examples, visit https://wix.to/94BuAAs
let fullText;
let shortText;
let shortTextLength = 50
$w.onReady(function () {
$w("#repeater2").onItemReady( ($item, itemData, index) => {
fullText = itemData.description
shortText = fullText.substr(0, shortTextLength) + "...";
$item("#description").text = shortText
});
$w("#button1").onClick( (event) => {
let $item = $w.at(event.context);
let clickedItemData = $item("#dataset1").getCurrentItem()
if ($item("#button1").label === "Show More"){
$item("#description").text = clickedItemData.description
$item("#button1").label = "Show Less"
} else {
fullText = clickedItemData.description
shortText = fullText.substr(0, shortTextLength) + "...";
$item("#description").text = shortText
$item("#button1").label = "Show More"
}
});
})
The show more/show less tutorial from Wix won't work in a repeater as it is designed to work alone by itself.
For limiting characters in a repeater you can just follow Nayeli (Code Queen) tutorial here and it will guide you through it easily.
Limit Characters using Wix Code in a Repeater | Load More Button
https://support.totallycodable.com/en/article/limit-characters-in-a-repeater-using-wix-code