Hello, I’m trying to have text cut off at 40 characters in a repeater that’s linked to a dataset. (I dont actually need a show more button) This is my code so far:
$w.onReady( function () {
//TODO: write your page related code here…
$w(“#dynamicDataset”).onReady( function () { const shortTextLength = 30;
fullText = $w(‘#dynamicDataset’).getCurrentItem().order; if (!fullText) {
$w(‘#myTextElement’).collapse();
} else {
display it as is and collapse the “Show More” button if (fullText.length <= shortTextLength) {
$w(‘#myTextElement’).text = fullText;
} else {
shortText = fullText.substr(0, shortTextLength) + “…”;
$w(‘#myTextElement’).text = shortText;
}
}
});
});
Does anyone know what I’m doing wrong? It keeps on showing the last element of my database for each container in the repeater.
Thank you for the help! I was also wondering what I would need to add if the repeater was connected to a dataset? So far it works but only when its not connected.