Forums › Forums › Search & Filter Pro › Infinite scroll issue
- This topic has 30 replies, 4 voices, and was last updated 3 years, 10 months ago by Ross.
-
Anonymous(Private) January 8, 2021 at 3:51 pm #272172
Hi Trevor
added the container with scroll into the results file and still no luck
Seems like the function triggers on window scroll but the scroll we have is on a container with overflow scroll. so not sure if this will work at all with overflow scroll content
Ross Moderator(Private) January 11, 2021 at 9:55 am #272292Hi Rachel
That’s correct, the infinite scroll is triggered when the window scrolls past a certain point in relation to the container – I don’t think this would work if its in a container with overflow.
I’ll stick this on the todo list for further investigation, as it would be nice to work the way you have mentioned – but for now this will not work.
Best
Ross Moderator(Private) January 12, 2021 at 5:02 pm #272558Hi Rachel
Right now our javascript api is a bit limited – we’ll be rewriting this in version 3, but for now you can do it like this:
(function ($) { "use strict"; let searchForm; $(document).on("sf:init", ".searchandfilter", function(e, data){ // copy to window so we can access it anywhere searchForm = data.object; console.log("S&F init", searchForm); }); $( 'a' ).on( 'click', function() { searchForm.loadMoreResults(); } ); })(jQuery);
To break it down, the first event
sf:init
is fired for each search form initialised after page load.We assume in this example there is only one, and we copy that to a variable
searchForm
.Then, on the
click
handler, we trigger aloadMoreResults();
– I’ve added the click event to anya
– so you’ll want to change that to your button class / ID I guess…Best
Anonymous(Private) January 13, 2021 at 9:09 am #272628Hi Ross
Thanks for the code snipper which i have added to the JS file.
However the click didnt work on either a tags or my class elements, but got it working with this click event
$(document).on( 'click', '.show-more', function() { searchForm.loadMoreResults(); } );
-
AuthorPosts