forItems( )


Runs a function for each repeated item with the given IDs.

Use the forItems() function to run a function on a specified list of repeated items. You can use the callback function to update or pull information from the specified repeated items.

When you set a repeater's data property with data that changes items with existing IDs, those changes are not automatically reflected in the elements contained in the repeater. That is because you are responsible for applying a repeater's data to its repeated items.

To apply the data to items with new IDs, you can use the onItemReady() event handler.

To update items with existing IDs, you can use the forEachItem() or forItems() functions.

Usually, when updating repeated items you:

  • Apply the repeated item's itemData to the properties and functions of the repeated elements contained in the repeated item being created.

    For example, you can use onItemReady() to set the src property of an image in the repeater to a mobile image source found in the itemData object and then show() the mobile image.

  • Add event handlers to the repeated elements contained in the repeated item being created.

    For example, you can use onItemReady() to set the onPress() event handler of a button in the repeater.

Method Declaration
Copy
Method Parameters
itemIdsArray<string>Required

The IDs of the items on which to run the callback function.


callbackfunctionRequired

callback($item: $w, itemData: object, index: number): void The name of the function to run for each repeated item.

Was this helpful?
Yes
No