Guest User

Untitled

a guest
Nov 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. //This file needs to be hooked at the bottom of theme.liquid right before the </body>
  2.  
  3. {% if template.name contains 'collection' %}
  4. {% assign product_per_page = 24 %}
  5. <script>
  6. $(document).ready(function() {
  7. var counter = 2
  8. var pages = Math.ceil('{{ collection.all_products_count }}' / {{ product_per_page }});
  9. var maxCount = pages + 1;
  10. console.log("Pages Found: " + pages);
  11.  
  12. console.log("Collection Title: {{ collection.handle }}");
  13.  
  14. $('#pagination a').on('click' , function(e) {
  15.  
  16. e.preventDefault();
  17.  
  18. var getUrl = "{{shop.url}}/collections/{{ collection.handle }}?page="+counter;
  19. console.log(getUrl);
  20. $.ajax({
  21. url: getUrl,
  22. type:'GET',
  23. // beforeSend: function() {
  24. // showPopup('.loading');
  25. // },
  26. success: function(data){
  27. //hidePopup('.loading');
  28. $(".devProductContainer").append($(data).find('.devProductContainer').html());
  29. counter++;
  30.  
  31. if(counter == maxCount ) {
  32. $('#more').empty();
  33. }
  34. }
  35. });
  36. });
  37. $(window).scroll(function() {
  38. if($(window).scrollTop() + $(window).height() == $(document).height()) {
  39. $('#pagination a').eq(0).trigger('click');
  40. console.log('clicked');
  41. }
  42. });
  43.  
  44. });
  45. </script>
  46. {% endif %}
Add Comment
Please, Sign In to add comment