Urgent. Keep Having to force exit editor/crashing editor with new repeater element and code

3 of 3:
I was looking at some help on pagination to see if that would accomplish seeing all items because the continuous scroll on mobile is important.

Your code could use some cleaning up, but it’s nothing that would be causing such a massive delay. 26ms at worst is, again, negligible. In my experience repeaters are not very efficient, and that is probably the culprit.

When you see an endless scroll list on a site, it’s coded to load efficiently…it doesn’t load everything at the same time because of the delay that would cause, and I imagine load times on mobile are even worse.

You’ll need to push data in chunks to the repeater using this:

I think you may want to find a simpler solution for now, and implement the endless scroll a bit delayed, because you will have to test it.

David,
I like the repeater because tables in wix aren’t so mobile friendly. They have a scroll bar pop up that is annoying.
Where do you see I can improve the code? Obviously, the continuous scroll is coded, I am not afraid of the coding and I am willing to try to push the data in chunks if that helps. I see what you posted, but do you have wix examples?

This array seems to be categorized by type and I don’t have types within the dataset.

I would rewrite your onready code like this, and connect the address and name through the editor, it doesn’t have to be done in code:

$w.onReady(() => {
$w(“#dataset1”).onReady(() => {
$w(“#repeater1”).onItemReady( ($item, itemData, index) => {
if (!itemData.email) {
$item(“#email”).hide();
} else {
$item(“#email”).link = ‘mailto:’ + itemData.email;
$item(“#email”).show();
}
if (!itemData.phone) {
$item(“#phone”).hide();
} else {
$item(“#phone”).link = ‘tel:’ + itemData.phone;
$item(“#phone”).show();
}
if (!itemData.website) {
$item(“#web”).hide();
} else {
$item(“#web”).url = itemData.website;
$item(“#web”).show();
}
});
});
});

But even then, this is the sort of thing where I would schedule a backend function to create a simplified version of only the data that will show up on the repeater, and then push it to the repeater based on the user’s scroll position. This is a lot of stuff to parse through, play with, and implement in just one day.

https://www.youtube.com/watch?v=tuu0D1izrUU
https://www.youtube.com/watch?v=n1d0FClxYMM

Thanks for this. I will work through it.

You could try changing !itemData arguments back to itemData === null. I only changed the order around a bit otherwise.

I fixed it. Thanks for the help!

I think using !itemData. is a better approach in a conditional test. It essentially tests for an unusable value (including empty string) which would pass a null test.

@elizabethjhay Your published site loads just fine. See this youtube video.

I think you are dealing with several things.

  1. The Wix Editor and preview functions do not run in a production environment per se. The server farms etc. are not what the published site will run on. This is how you can accomplish debugging etc using the Corvid environment.

  2. Another issue that I have encountered on my Mac is the Chrome browser resource management. I have had to restart my laptop on occasion to fix speed issues.

  3. In order to debug code in the browser there is a code build phase in the backend the generates a debug file that maps the javascript that runs in the browser to your actual code (these are different because the $w() elements are converted to HTML DOM elements in the back end so there is a translation that is done. If this isn’t generated in time this can delay loading of the page.

  4. Image rendering can be expensive. I note that you are using icons (which wasn’t obvious in the code :-)) for web, phone and email. The more of these that you have the longer it will take to render the page.

  5. Instead of using onItemReady to perform this work, have you tried forEachItem? One is an event that is generated by the wix environment the other is a loop which might be more efficient for what you need to do. You shouldn’t need to make many changes to your code because the function call and expectations of forEachItem are identical. You may save some time doing this.

  6. To load the repeater in pages you would need to implement a handler using onViewportEnter. A way to accomplish this is to add a transparent box to the end of the repeater. When it enters the view when you scroll up it can trigger a repeater update which you can accomplish using the forItems() function. When the repeater grows with the additional items the box should be pushed back out of the viewport. To do this you would need to manage the data in the repeater yourself vs relying on the dataset. This is where David’s suggestion to load data in backend would be more efficient which you would accomplish using the wixWindow.rendering.env property.

Hope these prove helpful.

Cheers
Steve

Steve, I think you are right