I have been trying to use render cycles to improve my page’s loading speed and the dynamics of the page.
When the page loads many times the repeater will first show the original wix repeater data which was included in original element i.e. Josie Lane.
For some reason though, when I try to get a repeater data to load during renderCycle 1, the repeater does not always load. What am I missing here?
The page is: https://www.ppa-mc.com/Webinars/Innovation-Unleashed/Navigating-Innovation-Today-to-Build-Value-Tomorrow
and the code is below. Many thanks in advance, Chris
import wixData from 'wix-data';
import { singleVariableQueryAscending } from 'backend/databaseQueries';
import wixWindow from 'wix-window';
const webinarHosts = "WebinarHosts"
$w.onReady(function () {
// This is a dataset on a dynamic page the _id is used to find hosts for the particular webinar
let data = $w("#eventData").getCurrentItem()
// Run if renderCycle is 1 this does not always work
if (wixWindow.rendering.renderCycle === 1) {
loadHosts(data)
}
});
// function to fill the repeater with data and update elements
export function loadHosts (data) {
// standard wixData.query which lives in the backend
singleVariableQueryAscending(webinarHosts, "webinarTitle", data._id, "priority")
.then((result) => {
// fill the "hosts" repeater with data
$w("#hosts").data = result
// Update the specific items in the repeater
$w("#hosts").forEachItem(($item, itemData, index) => {
$item("#host").text = itemData.firstName + " " + itemData.lastName
$item("#company").text = itemData.company
$item("#position").text = itemData.position
$item("#hostImage").src = itemData.hostImage
})
// Expand when complete
$w("#hosts").expand()
})
}