jQuery(document).ready( function() { var j = jQuery; j('#sortby-dropdown').val(''); j('#sortby-dropdown').change( function() { jQuery.blockUI({css:{width: '12%',top:'40%',left:'45%'}, message: jQuery('#blockUISpinner').show() }); var filter = j('#sortby-dropdown').val(); if ( filter == 'category' ) { var theaction = 'get_cats'; } else if ( filter == 'tag' ) { var theaction = 'get_tags'; } else { var theaction = 'default'; j('#filter').empty(); j('#filter').append(''); } j('#filter').val(''); j('#filter').trigger('change'); if (theaction == 'default') { j.unblockUI(); return true; } j.ajax({ url: ajaxurl, type: 'POST', timeout: 10000, data: {action:theaction}, success: function(response){ var s = response.split(','); j('#filter').empty(); if (filter == 'tag') { j('#filter').append(''); } else if (filter == 'category') { j('#filter').append(''); } else { j('#filter').append(''); } j.each( s, function(index, value) { var v = value.split(':'); var h = ''; //alert(h); return false; j('#filter').append(h); }); }, complete: function(){ j.unblockUI(); } }); }); j('#filter').change( function() { jQuery.blockUI({css:{width: '12%',top:'40%',left:'45%'}, message: jQuery('#blockUISpinner').show() }); var term = j('#filter').val(); var tagorcat = j('#sortby-dropdown').val(); if (tagorcat == '') { tagorcat = 'cat'; } j.ajax({ url: ajaxurl, type: 'POST', timeout: 10000, data: {action:'get_posts_by',term:term,tagorcat:tagorcat}, success: function(response){ var s = response.split(','); j('#sidebar-posts').empty(); j.each( s, function(index, value) { var v = value.split(':'); var h = '
  • ' + v[1] + '

  • '; j('#sidebar-posts').append(h); }); anthologize.initSidebar(); }, complete: function(){ j.unblockUI(); } }); }); });