top of page

Forum Posts

Richard Hogan
Jul 31, 2019
In Coding with Velo
I am working on a site for a customer and it seems that the .getCurrentItem() does not work when using a collection/dataset. All other items in the repeater seem to be working fine, but the text element that I am trying to pull in dynamically doesn't come in. I assume it's because of the .getCurrentItem(). I followed the tutorial here: https://support.wix.com/en/article/corvid-tutorial-creating-a-show-more-link Any suggestions or recommendations that would allow me to get the .bio text from each record in my collection and not just the first one? Here is my code: $w.onReady( () => { $w("#facultyDataset").onReady( () => { // how many characters to include in the shortened version const shortTextLength = 90; // set the fullText variable to be the text from the collection fullText = $w('#facultyDataset').getCurrentItem().bio; // if no text to display, collapse the text element and the button if (!fullText) { $w('#facultyBio').collapse(); $w('#readMore').collapse(); } else { // if the text has fewer or the same number of characters as shortTextLength characters, display it as is and collapse the "Show More" button if (fullText.length <= shortTextLength) { $w('#facultyBio').text = fullText; $w('#readMore').collapse(); } else { // create the shortened version of the text and display it in the text element shortText = fullText.substr(0, shortTextLength) + "..."; $w('#facultyBio').text = shortText; } } }); }); export function readMore_click(event) { // check the contents of the text element if ($w("#facultyBio").text === shortText) { // if currently displaying short text, display the full text $w("#facultyBio").text = fullText; $w("#readMore").label = "Show less"; } else { // if currently displaying full text, display the short text $w("#facultyBio").text = shortText; $w("#readMore").label = "Show more"; } }
0
4
426

Richard Hogan

More actions
bottom of page