Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ajax filtering
- $('.cat-list_item').on('click', function(e) {
- e.preventDefault();
- $('.cat-list_item').removeClass('active');
- $(this).addClass('active');
- $.ajax({
- type: 'POST',
- url: '/wp-admin/admin-ajax.php',
- dataType: 'json',
- data: {
- action: 'filter_projects',
- category: $(this).data('slug'),
- },
- success: function(res) {
- currentPage = 1;
- $('.post-filter').html(res.html);
- $('.card').each(function(i) {
- // 'i' stands for index of each element
- $(this).delay(i * 400).fadeIn(600);
- });
- }
- })
- });
- // ajax load more
- let currentPage = 1;
- $('#load-more').on('click', function() {
- currentPage++;
- $.ajax({
- type: 'POST',
- url: '/wp-admin/admin-ajax.php',
- dataType: 'json',
- data: {
- action: 'load_more_projects',
- category: $(this).data('slug'),
- paged: currentPage,
- },
- success: function (res) {
- if(currentPage >= res.max) {
- $('#load-more').hide();
- }
- $('.post-filter').append(res.html);
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement