Repeater isn't pulling values

I’m having trouble with
A repeater was working, now it isn’t. I changed the name of the repeater - changed the name in the code - and that broke it. I know the code is messy - I’m sort of learning as I go, and doing this in my spare time for a not-for-profit.

Working in
Dev mode

What I’m trying to do
Input the member name (first, last, email) in the membership database, take the member ID from that and search the declared horse database to get the horse names assigned to that person – stored in an array. I taught myself how to assign an id to the names so they can be shown on the repeater. I got this to work on a different page, but now it won’t work on my current one. It’s the same code, but it doesn’t work now.

What I’ve tried so far
I’ve double checked element names, quotation marks, typos, semi-colons. I tried deleting the repeater and making a new one - which helped the first time the code wouldn’t work. The array of names prints fine in the console, but it seems like the repeater never gets to “onReady.”

Code on Page:

// Velo API Reference: https://www.wix.com/velo/reference/api-overview/introduction
import wixData from 'wix-data';
import { horsepointtotal } from 'backend/highpointsearch.jsw';


$w.onReady(function () {

    //Repeaters
    $w('#myhorsetotals').onItemReady(($item, itemData) => {
        $item('#HorseName').text = itemData.horseName;
    });

    //Search Buttons
    $w('#horsetotalsSearchButton').onClick(async () => {
		
        $w('#horsetotalsSection').expand();
        const fname = $w('#fnameInput').value;
        const lname = $w('#lnameInput').value;
        const email = $w('#emailInput').value;

        const horsenames = await horsepointtotal(fname, lname, email);
        
        $w('#myhorsetotals').data = [horsenames.horsequeryResultsData];
        console.log(horsenames.horsequeryResultsData)

    });
});

//SubMenu Navigation
$w('#horsetotalsButton').onClick((event) => {
    $w('#horsetotalsSearchMenu').expand();
    $w('#performanceSearchMenu').collapse();
    $w('#equitationSearchMenu').collapse();
    $w('#academySearchMenu').collapse();
})
$w('#performanceButton').onClick((event) => {
    $w('#horsetotalsSearchMenu').collapse();
    $w('#performanceSearchMenu').expand();
    $w('#equitationSearchMenu').collapse();
    $w('#academySearchMenu').collapse();
})
$w('#equitationButton').onClick((event) => {
    $w('#horsetotalsSearchMenu').collapse();
    $w('#performanceSearchMenu').collapse();
    $w('#equitationSearchMenu').expand();
    $w('#academySearchMenu').collapse();
})
$w('#academyButton').onClick((event) => {
    $w('#horsetotalsSearchMenu').collapse();
    $w('#performanceSearchMenu').collapse();
    $w('#equitationSearchMenu').collapse();
    $w('#academySearchMenu').expand();
})

Code in .jsw file:

import wixData from 'wix-data';

export async function horsepointtotal (fname, lname, email) {
    const fnameQuery = wixData.query("2026membership").eq("fname", fname);
    const lnameQuery = wixData.query("2026membership").eq("lname", lname);
    const emailQuery = wixData.query("2026membership").eq("email", email);
    const membersearchQueryResults = await fnameQuery
        .and(lnameQuery)
        .and(emailQuery)
        .find();

    if (membersearchQueryResults.items.length > 0) {
        // const membersearchQueryData = membersearchQueryResults.items;

        const memberID = membersearchQueryResults.items[0]._id;
        const horseQuery = wixData.query("2026declaredhorses").eq("memberid", memberID);
        const horsequeryResults = await horseQuery.fields("declaredHorses").find();

        const horsequeryResultsData = horsequeryResults.items[0].declaredHorses.map((name, index) => ({
            _id: index.toString(),
            horseName: name
        }))

        return {horsequeryResultsData}
    }
}

Screenshot:

1 Like

Hi!
A few questions:

  • Are you getting any errors in your editor?
  • Is the site published? Did you publish the repeater name change?

Also, I believe

$w('#myhorsetotals').data = horsenames.horsequeryResultsData;

should be used instead of

$w('#myhorsetotals').data = [horsenames.horsequeryResultsData];

You might also want to check if your variables have something stored (like horsequeryResults.items[0], for example).

I hope it helps!
Cheers!

2 Likes

Well that was incredibly simple. Removing the brackets ([, ]) around the result I was sending to the repeater fixed it. I could have sworn that’s how I had it on a different repeater but maybe I misremembered and accidentally changed it at some point.

I will surely be back with more questions in a new post, but for now that solved it. Thank you so much!