Hi, I followed this guide but have found it’s limited to static text boxes and not dynamic collections using repeaters which I’m using to show a set of events.
https://support.wix.com/en/article/wix-code-tutorial-creating-a-show-more-link
The result is that the text stays the same for every repeater in the collection.
Can anyone please help with the additional code required to ensure that the text associated to the repeater is shown?
sapirh
January 16, 2019, 3:27pm
2
Hi Adam,
Can you please send a URL to your site and specify the name of the page so we can inspect?
Best,
Sapir
if You use it in repeater You need to do to foreach function. I had the same problem and after foreach it works
Thanks is there any example code please? I’m quite limited in my JS skills.
sapirh
January 22, 2019, 1:42pm
6
Hi Adam,
First, disconnect the element text ($w(‘#text8 ’)) from the dataset because you are already add the event description to this element in your code.
Second, use onItemReady() function and view this code. ( I used the function you wrote and added the onItemReady() function)
Here you can read more about this function, read what each parameter represent.
$w.onReady(function () {
$w("#dynamicDataset").onReady(function () {
$w('#repeater1').onItemReady(($item, itemData, index) => {
const shortTextLength = 50;
fullText = itemData.eventDescription;
if (!fullText) {
$w('#text8').collapse();
$w('#button5').collapse();
} else {
if (fullText.length <= shortTextLength) {
$w('#text8').text = fullText;
$w('#button5').collapse();
} else {
shortText = fullText.substr(0, shortTextLength) + "...";
$w('#text8').text = shortText;
}
}
});
});
});
Best of luck,
Sapir
Hi - I gave this as go and get the same result, not sure what I’m doing wrong!