While trying to debug, I have simplified and hardcoded it to go to page 2 of a dataset.
$w('#productsList').onReady(function () {
$w('#productsRepeater').onItemReady(productItemReady)
// updateFilterSelectedN()
// reloadProductsBasedOnFilter()
// sortProducts()
$w('#productsList').loadPage(2)
})
When I load the page, I get this error in the developer console and it fails to load:
supplementaryErrorHandlers.js:22 Wix code SDK error: The currentPage parameter that is passed to the currentPage method cannot be set to the value 1.75. It must be of type integer,null.
As you can see 2 is being passed into the loadPage() but developer console shows it receiving 1.75. If I pass in a 3 it spits an error saying it got 2.5.
If I set up a test button and have it perform the loadPage(pgNumber) it performs fine for some reason, but when I have it within the onReady function it doesn't work at all.
Hey @Brian, I didn't forget about you. I was trying to clear up the issue of public files. And it's like this…
The masterPage.js file is if you want to add processing for your header or footer, and to handle elements that you want to put on every page (with the same element ID). This file has its own onReady() event handler.
The main idea behind Public code files is for code reuse. The Public section is where you put JavaScript files that contain the code you want to use on multiple pages in your site, without having to include the code on each page. As with the masterPage.js file, you can access page elements from Public files. The problem is that you can't be sure from which page the Public files are used and it follows that you can't be sure which components are available on the page. So, while it is possible, it is not encouraged.
The masterPage.js file and Public files, are intended for different uses, but are similar in that they both have the same scope, and that you can access page elements from both types of files. For Public code, best practice is to pass the elements from the page code to the public files.
Cheers 🍻
I noticed that you have a number of errors in your code. For example:
The WixDataSort API does not have the orderBy property. See the WixDataSort API for details. You'll need to fix these errors, as well as the errors in the other files and pages. Some of the errors occur in the Public code files since the $w namespace is not accessible from these files. You'll have to reorganize your code to adjust for this.
Strange. One thing I noticed (which I don't think makes any difference) is that you are defining the onItemReady() function inside the dataset onReady() function. It really should be in the page's onReady() and not the dataset's onReady(). Something like this:
$w('#productsRepeater').onItemReady(productItemReady) $w('#productsList').onReady( function() { // updateFilterSelectedN() // reloadProductsBasedOnFilter() // sortProducts() $w('#productsList').loadPage(2) })
If you're still having issue, please post the URL of your site and explain where and how I can see the issue.