Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This file needs to be hooked at the bottom of theme.liquid right before the </body>
- {% if template.name contains 'collection' %}
- {% assign product_per_page = 24 %}
- <script>
- $(document).ready(function() {
- var counter = 2
- var pages = Math.ceil('{{ collection.all_products_count }}' / {{ product_per_page }});
- var maxCount = pages + 1;
- console.log("Pages Found: " + pages);
- console.log("Collection Title: {{ collection.handle }}");
- $('#pagination a').on('click' , function(e) {
- e.preventDefault();
- var getUrl = "{{shop.url}}/collections/{{ collection.handle }}?page="+counter;
- console.log(getUrl);
- $.ajax({
- url: getUrl,
- type:'GET',
- // beforeSend: function() {
- // showPopup('.loading');
- // },
- success: function(data){
- //hidePopup('.loading');
- $(".devProductContainer").append($(data).find('.devProductContainer').html());
- counter++;
- if(counter == maxCount ) {
- $('#more').empty();
- }
- }
- });
- });
- $(window).scroll(function() {
- if($(window).scrollTop() + $(window).height() == $(document).height()) {
- $('#pagination a').eq(0).trigger('click');
- console.log('clicked');
- }
- });
- });
- </script>
- {% endif %}
Add Comment
Please, Sign In to add comment