Forums › Forums › Search & Filter Pro › Infinite scroll masonry
Tagged: infinite scroll masonry
- This topic has 13 replies, 3 voices, and was last updated 7 years, 5 months ago by Anonymous.
-
Trevor(Private) May 31, 2017 at 9:04 am #112222
Hi
Infinite scroll uses Ajax to load the ‘next’ posts, and so you need to do two things:
#1 Detect when our ajax has finished, for which we have a script snippet
#2 Re-run the masonry script on the posts/posts containerYour major problem will be #2 therefore. Each theme seems to implement masonry differently (assuming your theme actually uses Masonry, and not a look-a-like script like Salvattore). Some themes sensibly create a function to do this, and then run that on document ready. That makes life easier. Some simply run a long script on document ready, part of which does the actual masonry bit on the posts. That makes it very hard. You will need the help of your theme author.
I will give an example here, in this case for the Divi theme (which uses Salvattore):
<script>(function ( $ ) { "use strict"; $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ console.log("ajax complete"); var grids = document.getElementsByClassName('et_pb_blog_grid'); salvattore['register_grid'](grids[0]); }); }(jQuery));</script>
In the above, the part that re-runs the Salvattore script in Divi is these two lines:
var grids = document.getElementsByClassName('et_pb_blog_grid'); salvattore['register_grid'](grids[0]);
Which is relatively easy.
In essence, it boils down to what theme you are using and if the author of it can help you with this. In the above example, Elegant Themes (the author of Divi) could not help, but as Salvattore is so easy to implement, we figured it ourselves with the help of a third party web site code snippet.
Anonymous(Private) May 31, 2017 at 10:56 am #112238Hi thanks for the reply
I used a custom theme based on foundation (joints wp).
I tried
$( document ).on(“sf:ajaxfinish”, “.searchandfilter”, function() {
$(‘#masonry-container’).masonry({
itemSelector: ‘#masonry-container .grid-item’
});
});But no effect…
Ross Moderator(Private) May 31, 2017 at 12:25 pm #112260What happens if you put a
console.log('ajax finish');
in in thesf:ajaxfinish
event, do you see this come up in the console? -
AuthorPosts