I am trying to limit the number of characters displayed in a database repeater text box. (For example, I want to display only 50 characters even if the data is 100 characters etc. )
I was able to do this (code below), but now I have this problem:
The code limiting the characters only works the first time the page loads. When you go to page 2 or come back to page 1, the code no longer works and the full length data is displayed.
My site uses pagination.
Here is my code:
$w.onReady(function () {
$w("#dataset1").onReady(() => {
$w("#repeater1").forEachItem(($w) => {
let text = $w("#dataset1").getCurrentItem().authors;
console.log(text);
let shortenedtext = text.slice(0, 10);
if (text.length > 50) {
$w("#authors").text = shortenedtext+" et al ";
}
})
})
})
Does it have something to do with the onReady function? Or something else?
All help is appreciated.
Thank you!