dgpope

Js file for loading content

Mar 9th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery(document).ready(function($) {
  2.     $('.tax-filter').click( function(event) {
  3.  
  4.         // Prevent default action - opening tag page
  5.         if (event.preventDefault) {
  6.             event.preventDefault();
  7.         } else {
  8.             event.returnValue = false;
  9.         }
  10.  
  11.         // Get tag slug from title attirbute
  12.         var selecetd_taxonomy = $(this).attr('title');
  13.  
  14.         // After user click on tag, fade out list of posts
  15.         $('.tagged-posts').fadeOut();
  16.  
  17.         data = {
  18.             action: 'filter_posts', // function to execute
  19.             afp_nonce: afp_vars.afp_nonce, // wp_nonce
  20.             taxonomy: selecetd_taxonomy, // selected tag
  21.             };
  22.  
  23.         $.post( afp_vars.afp_ajax_url, data, function(response) {
  24.  
  25.             if( response ) {
  26.                 // Display posts on page
  27.                 $('.tagged-posts').html( response );
  28.                 // Restore div visibility
  29.                 $('.tagged-posts').fadeIn();
  30.             };
  31.         });
  32.     });
  33. });
  34. jQuery(document).ready(function($) {
  35.     $('.term-filter').click( function(event) {
  36.  
  37.         // Prevent default action - opening tag page
  38.         if (event.preventDefault) {
  39.             event.preventDefault();
  40.         } else {
  41.             event.returnValue = false;
  42.         }
  43.  
  44.         // Get tag slug from title attirbute
  45.         var selecetd_taxonomy = $(this).attr('title');
  46.  
  47.         // After user click on tag, fade out list of posts
  48.         $('.tagged-posts').fadeOut();
  49.  
  50.         data = {
  51.             action: 'filter_terms', // function to execute
  52.             afp_nonce: afp_vars.afp_nonce, // wp_nonce
  53.             taxonomy: selecetd_taxonomy, // selected tag
  54.             };
  55.  
  56.         $.post( afp_vars.afp_ajax_url, data, function(response) {
  57.  
  58.             if( response ) {
  59.                 // Display posts on page
  60.                 $('.tagged-posts').html( response );
  61.                 // Restore div visibility
  62.                 $('.tagged-posts').fadeIn();
  63.  
  64.             };
  65.         });
  66.     });
  67. });
  68.  
  69. jQuery(document).ready(function($) {
  70.     $('.ajax-click').click( function(event) {
  71.  
  72.         // Prevent default action - opening tag page
  73.         if (event.preventDefault) {
  74.             event.preventDefault();
  75.         } else {
  76.             event.returnValue = false;
  77.         }
  78.  
  79.         // Get post ID from id attirbute
  80.         var post_id = $(this).parent("li").attr("id");
  81.  
  82.         // After user click on tag, fade out list of posts
  83.         $('#post-content').fadeOut();
  84.  
  85.         data = {
  86.             action: 'load-content', // function to execute
  87.             afp_nonce: afp_vars.afp_nonce, // wp_nonce
  88.             post_id: post_id, // selected tag
  89.             };
  90.  
  91.         $.post( afp_vars.afp_ajax_url, data, function(response) {
  92.  
  93.             if( response ) {
  94.                 // Display posts on page
  95.                 $('#post-content').html( response );
  96.                 // Restore div visibility
  97.                 $('#post-content').fadeIn();
  98.  
  99.             };
  100.         });
  101.     });
  102. });
Add Comment
Please, Sign In to add comment