Created
October 15, 2025 15:03
-
-
Save ahmadajmi/f2e2e5ac13d86fc014b17781c011f356 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| (function ($) { | |
| $(function () { | |
| var $btn = $('.js-load-cards'); | |
| if (!$btn.length) return; | |
| $btn.off('click.tripoliFix').off('click').on('click.tripoliFix', function (e) { | |
| e.preventDefault(); | |
| e.stopImmediatePropagation(); | |
| if ($btn.data('loading') || $btn.hasClass('c-btn--disabled') || $btn.is(':disabled')) return; | |
| var total = Number(window.pagination_available_pages_number || 0); | |
| var nextHref = $('link[rel=next]').attr('href'); | |
| if (!nextHref) return; // No pagination available | |
| var n = Number( | |
| window.pagination_next_page_number || | |
| parseInt((nextHref.match(/\/page\/(\d+)/) || [,'2'])[1], 10) | |
| ); | |
| if (total && n > total) { | |
| $btn.addClass('c-btn--disabled').attr('disabled', true); | |
| return; | |
| } | |
| var url = String(nextHref).replace(/\/page\/\d+\/?$/, '/page/' + n + '/'); | |
| $btn.data('loading', true).addClass('c-btn--loading'); | |
| $.get(url).done(function (data) { | |
| $('.js-grid').append($('.js-card', data)); | |
| window.pagination_next_page_number = n + 1; | |
| if (total && window.pagination_next_page_number > total) { | |
| $btn.addClass('c-btn--disabled').attr('disabled', true); | |
| } | |
| }).fail(function () { | |
| $btn.addClass('c-btn--disabled').attr('disabled', true); | |
| }).always(function () { | |
| $btn.data('loading', false).removeClass('c-btn--loading'); | |
| }); | |
| }); | |
| }); | |
| })(window.jQuery); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment