Hello - Wondered if someone could help with the code below? I’m trying to accomplish with my site, the same results someone else was able to create with their site. To see successful examples (https://www.ultimatecalloutchallenge.com/2019/UCC/Competitors)
- I am using repeaters linking to dynamic item pages
- I would like to pull the individual elements from my database collection, into each repeater.
- So far this is successful, except for the ‘Full Text’ item that displays a truncated paragraph (55 character display). Currently the code is pulling the ‘current’ item, and each repeater is pulling the same ‘full text’ instead of the matching individual ‘full text’ for each individual repeater. I believe the error is in the line 6 of text below at:
let fullText = $w(‘#dataset1’).getCurrentItem().fullAnswer;
Is there a substitution for CurrentItem, to instead pull each ‘individual item’ from the collection?
$w.onReady( function () {
$w(“#dataset1”).onReady( function () {
// how many characters to include in the shortened version
const shortTextLength = 55;
// set the fullText variable to be the text from the collection
let fullText = $w(‘#dataset1’).getCurrentItem().fullAnswer;
// if no text to display, collapse the text element and the button
if (!fullText) {
$w(‘#text32’).collapse();
$w(‘#button5’).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(‘#text32’).text = fullText;
$w(‘#button5’).collapse();
} else {
// create the shortened version of the text and display it in the text element
let shortText = fullText.substr(0, shortTextLength) + “…”;
$w(‘#text32’).text = shortText;
}
}
});
});