Hi,
I wrote an onReady function for a DataSet in order to trim the text for my repeater. However it doesn’t get invoked the first time. If I refresh the page, it works. Can someone tell me how to make this work everytime. What am i doing wrong? Here is the code:
$w.onReady( function () {
//TODO: write your page related code here…
$w(“#dataset3”).onReady( function () {
const shortTextLength = 160;
let fullText;
let shortText;
let headingText;
$w(“#repeater1”).forEachItem(($w, item) => {
fullText = $w(‘#text27’).text;
if (!fullText.length) {
$w(‘#text27’).collapse();
} else
if (fullText.length <= shortTextLength) {
$w(‘#text27’).text = fullText;
} else {
shortText = fullText.substr(0, shortTextLength) + “…”;
$w(‘#text27’).text = shortText;
}
//If heading is long truncate it.
headingText = $w(‘#text26’).text;
if (headingText.length > 12)
{
headingText = headingText.substr(0, 14) + “…”;
$w(‘#text26’).text = headingText;
}
})
});
});