I've created a view that has Infinite scroll with the load more button, it used to work, but now it doesn't.
I have added this code below in the Loop editor JS section to remove auto-load (which use to work before)
jQuery(function($){
WPViews.view_pagination.is_infinite_triggable = function(view_layout){return false; }
});
In the console, there's this error "jquery.min.js?ver=3.5.1:2 Uncaught ReferenceError: WPViews is not defined" (screenshot attached), so I believe that's the reason why it's not working. I can't seem to fix that 'WPViews is not defined' error.
It seems after updating the toolset view plugin to the latest version, it start to have this error. Can this be fixed?
Just to add, when I downgraded the toolset view plugin to version 3.4.2, it's working again.
So all the versions of 3.5 and up are not working for me. It's giving me the 'Uncaught ReferenceError: WPViews is not defined' error message.
Hello. Thank you for contacting the Toolset support.
With the latest views/blocks plugin the pagination script is not enqueued on pages without pagination. Infinite scroll doesn't count as pagination, so to access the WPViews object you will need to enqueue the script manually, because of the asset optimisation changes to avoid loading scripts where not needed.
Can you please try to add the following code to your theme's functions.php file and see it that help you to resolve your issue.
Thank Minesh! The error is gone in the console, but the load more button is still not resolved yet.
Under 'Pagination and Sliders Settings', I've selected 'Pagination enabled with manual transition and AJAX' and in the Pagination options, the Transition effect is Infinite scrolling (Capture.PNG screenshot). Removing the auto-load js code isn't working which used to work (Capture2.PNG screenshot):
This is a working version (with toolset view plugin version 3.4.2): hidden link
This is not a working version (latest version of the toolset view plugin ): hidden link
As you can see on the working version, when you scroll down near the end, the load more button stays in the view , so the js code for removing the auto-load works. If you click on it, it will load more posts. But now with the latest version of the toolset view plugin, once you scroll near the end, the load more button is visible for a second then disappears, so the js code for removing the auto-load isn't working.
Does this code work anymore? Or is there a new code for removing the auto-load if the Transition effect is 'Infinite scrolling'?
jQuery(function($){
WPViews.view_pagination.is_infinite_triggable = function(view_layout){return false; }
});