Just got this working on my site, it works if the #text39 is not connected to the repeater in the template and #button1 starts with the label “Show More” also you need to add your own database field instead of mine (description) at itemData.description & clickedItemData.description :
let fullText;
let shortText;
let shortTextLength = 300
$w.onReady( function () {
$w("#repeater1").onItemReady( ($item, itemData, index) => {
fullText = itemData.description
shortText = fullText.substr(0, shortTextLength) + "...";
$item("#text39").text = shortText
});
$w("#button1").onClick( (event) => {
let $item = $w.at(event.context);
let clickedItemData = $item(“#dataset1”).getCurrentItem()
if ($item(“#button1”).label === “Show More”){
$item("#text39").text = clickedItemData.description
$item("#button1").label = "Show Less"
} **else** {
fullText = clickedItemData.description
shortText = fullText.substr(0, shortTextLength) + "...";
$item("#text39").text = shortText
$item("#button1").label = "Show More"
}
});
})