Repeater problems

Hello,


I’ve been having this issue for a while now - but it’s even more pronounced on my mobile site.

For my repeater, I show 5 items to start on the page: https://www.deafliteracy.ca/News. There is a “more” button at the bottom of the list - which loads another 5 items for each click. After 2 or 3 clicks (sometimes it might take more), the repeater fails to populate, instead showing the placeholder text for each item (see screen shot).

Can others confirm this on their computers and/or mobile devices?

Can someone help me to resolve this issue? Is there code I can add so that the repeater will load reliably? Or, is this a glitch??

Thanks!
Wanda

P.S.
This is the code I’m using for the page:

import wixData from 'wix-data';

$w.onReady(function(){
      $w("#dataset1").onReady(() => {
          repeaterRender();
    });
});

export function button2_click(event, $w) {
    repeaterRender();
}

function repeaterRender() {
   $w("#repeater1").onItemReady(() => {
        $w("#repeater1").forEachItem( ($w, dataset1, index) => {
 if (dataset1.pdfOrLink === "pdf") {
               $w("#viewPDF").show();
                $w("#viewPDF").target = "_blank"
               }
 else if(dataset1.pdfOrLink === "link") {
               $w("#viewURL").show();
               $w("#viewURL").target = "_self"
 if (dataset1.news === "Newsletter"){
                    $w("#viewURL").target = "_blank";
                }     
            }              
        });
   });
}

Your use of the Repeater functions is not quite right. You need to declare the Repeater’s onItemReady() handler in the page’s onReady() handler. See this article for a usage example . Since the onItemReady() function is called for each repeater item as it is ready, then calling the forEachItem() function from the onItemReady() function is incorrect.

Refer to the Repeater API for more details.

Good luck,

Yisrael

Hi Yisrael,

I should have mentioned that I am not really a coder - I’m just piecing bits together from what I can find. I had a look at the two links you provided, and I’m not really sure how to apply them to my situation. If you could instead show me where/how to fix my code specifically, that would help a lot more.

What I can’t understand is why the code I’m currently using works perfectly when I preview it from the editor… then it’s hit or miss when I view it from my published site (success rates vary over different browsers), and then when I look at it on my iPhone (Safari), it stops working every time on the second click of the “more” button. If my code is completely wrong, why does it work sometimes??

Thanks,
Wanda

Do you want the news to load five items at a time? Or is that just something that happened by accident and you’re trying to control it? I don’t see anything in your code that purposely loads 5 items or purposely loads “more” items.

I’m guessing you want to load all your items, and you have different kinds of items and you’ve created different buttons that you are showing or hiding depending on the item type.

This shouldn’t be necessary, you can just have one button that is always shown and contains the appropriate links to different item types. This can all be set up in your data table, you can load everything at once, and you shouldn’t need any code at all.

Would help to know what you would like.

(From an ex Torontonian!)

Hello Wanda
you set the button to load more, so you don’t need the function repeatRender().
would you please try it out with only linking the button (don’t use the function).

Massa

Thanks for the help Massa!

Removing the code for the load more button solved the problem! I had it there originally because in an earlier incarnation of the code, the repeater wasn’t showing the buttons for the links / pdfs properly. Now it seems all is in place, and it’s working perfectly!

BTW - Jharuni, the 5 at a time thing was set up through the dataset settings window. There are a couple dozen items (dating back to 2009), and I didn’t want the user to have them all on the page unless they purposely wanted to go back further.

In any case, all is well - so thanks again for the help everyone!!

Wanda