I use a repeater on my page to show items from a collection displaying 8 items at a time and everything works just fine. However, I'd like to be able to execute a piece of code, but, not until after the data has loaded into the repeater. For instance if I were to run this code:
$w("#myRepeater").data = myData
myFunction()
execution would return from the assignment of data right away. But, it takes a couple more seconds to actually load the data and see the results. It's as if the call to set the data is returning a promise.
I would like to be able to wait until the data has actually loaded into the repeater and then execute my function. Is there an event or handler that can be used to run a function once the data has finished loading into a repeater?
Thanks for any help or advice.
@gd_law There may be a better way, but it seems to me the following may be the closest you're going to get. The onItemReady sets the function that runs when a new repeated item is created. So, what you could do is get a count of the repeater items to be loaded ahead of time (RepeaterCount), and put in some code like this that runs when the last item is dealt with.
export function repeater1_itemReady($item, itemData, index) { if (index === RepeaterCount){ console.log("function could run here."); } }