Coding Dataset Connections - Instancing Problem

Can you help me determine why one connection is pulling individual items from my dataset, and why one connection is repeating the same combination from my dataset?

I believe I am using Wix Studio Editor, unsure how to verify it.

I am running two snippets of code on my repeater. Both are referencing different fields from the same dataset. One snipped of code (the working one) is limiting the characters in a specific text box. This is working fine.
The second snippet of code is supposed to combine multiple fields within one text box. It is combining the text perfectly, but it is repeating the same instance over and over, instead of including all the specified instances.

As a code-limited graphic designer, I need some help assessing what’s failed in this code and determining how to get it working.

Thanks!

/*—Start of Limit Characteer of Repeater */
$w.onReady( () => {
$w(“#dynamicDataset”).onReady( () => {

$w("#listRepeater").onItemReady( ($item, itemData, index) => {
  let theItem = itemData.messageDescription;
  var messageDescription = theItem.substr(0,250); //Change your character limit here
  $item("#descriptiontext").text = messageDescription + " . . . ";
});

} );
} );

/*—Start of Combine Details */
$w.onReady(() => {
const dataset = $w(“#dynamicDataset”);
dataset.onReady(() => {
const { speaker, series, subtitle, date } = dataset.getCurrentItem();
$w(“#messageDetails”).text = ${speaker} - ${series}: ${subtitle} | ${date};
});
});

Is #messageDetails a Text element inside of the repeater? If so, using $w on a repeated element will cause the last item’s data to be replicated across all repeated elements on the page.

To set repeated Text element based on each item (instance) of a repeater, the logic should belong inside of the $w("#listRepeater").onItemReady() with a $item() selector similar to the logic you provided for setting the #descriptiontext

Example

// Inside of $w("#listRepeater").onItemReady()

$item(“#messageDetails”).text = ${itemData.speaker} - ${itemData.series}: ${itemData.subtitle} | ${itemData.date};

Note: This assumes the itemData for each item has sufficient data to properly create this concatenated string.

For more information on how repeaters work, check out the following document:

1 Like