I have a repeater that is populated by code - not connected to a dataset. The code posted below produces a query that provides data for the repeater. This works perfectly except for only showing the first three items.
I have tried the Viweport approach to try to load more items as you scroll down. Can’t get that to work. However, if I connect the repeater to a dataset through the GUI I can get it to load all the items using the Viewport idea.
Several reasons for using a query rather than connecting using the GUI. The main reason is that I am using a reference field and the query allows me to connect and use elements from the referenced dataset. Also, I want to use the query idea in more complex situations elsewhere in the site.
Can anyone help me figure out how to load more items when scrolling down through the repeater? Thank for any ideas.
import wixData from ‘wix-data’ ;
$w.onReady( async function () {
let result = await wixData.query( “Projects2” )
.include( “categoryId” )
.eq( “projectsInclude” , true )
.limit( 30 )
.find()
await connectRepeater(result.items)
});
function connectRepeater(repeaterItems) {
$w( ‘#repeater1’ ).forEachItem(($w, itemData, index) => {
// connect each repeater item elements to their data from repeater data
$w( ‘#text14’ ).text = repeaterItems[index].projectName
$w( ‘#text12’ ).text = repeaterItems[index].projectDescription
$w( ‘#text44’ ).text = repeaterItems[index].projectDetails
$w( ‘#text13’ ).text = repeaterItems[index].categoryId._id
$w( ‘#text42’ ).text = repeaterItems[index].categoryId.categoryName
$w( ‘#text43’ ).text = repeaterItems[index]._id
$w( ‘#image5’ ).src = repeaterItems[index].image1
})
}
export async function columnStrip9_viewportEnter(event) {
// This function was added from the Properties & Events panel. To learn more, visit Velo: Working with the Properties & Events Panel | Help Center | Wix.com
// Add your code for this event here:
$w( “#image9” ).show(); //This is your GIF or animated image
await wixData.query( “Projects2” ).find() //This is your dataset
.then(() => {
$w( “#image9” ).hide(); //This is your GIF or animated image
});
}