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?
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.
Https://www.wix.com/code/reference/$w.Repeater.html#onItemReady
$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
if You use it in repeater You need to do to foreach function. I had the same problem and after foreach it works
Here's the URL: https://www.winefomo.com.au/all-events
Hi Adam,
Can you please send a URL to your site and specify the name of the page so we can inspect?
Best,
Sapir