I’m having trouble with
I’ve added code to truncate a text field in a repeater to a certain length. I also am using the selector tags input element on this repeater (connected to the database tag element). When I test the selector tag, I click either of them once, it works fine. If I then de-select, the velo code that truncates the description length no longer works.
Working in
Wix Editor
Site link
What I’m trying to do
I added some velo code to shorten the description length in the repeater to 100 characters, no matter how long the actual description text entered is. It’s working great, until I select one of the selection tags. For example, if on the site, you load the page, select ‘ebook’ and then click ‘ebook again’, you’ll see that the description of the item under the OTHER tag (infographic) is no longer cutting off at 100 which makes the repeater containers different heights. Same if you then select infographic and then unselect it—as soon as the eBook item reappears, its description is no longer truncated.
What I’ve tried so far
I tried looking into the selector tag events to see if I could re-run this code when an onChange event happens, but that didn’t work.
Extra context
Velo code:
$w.onReady(function () {
$w("#dynamicDataset").onReady( function () {
$w("#listRepeater").forEachItem( ($item, itemData, index) => {
const shortTextLength = 100; // Set your desired character limit
let fullText = itemData.descriptionOfResource;
if (fullText.length > shortTextLength) {
let shortText = fullText.substr(0, shortTextLength) + "...";
$w('#description').text = shortText;
} else {
$w('#description').text = fullText;
}
});
});
});
