CONTEXT
I'm using a a Wordpress plugin (Search & Filter Pro) to filter posts by category and load results via Ajax. Since I have several categories-of-categories (e.g. authors, topics, etc.), I added the code below to make the each super-category behave as an accordion:
jQuery(function($) {
$('li h4').on("click", function(){
console.log('hello!')
//Expand or collapse this panel
$(this).next().slideToggle('slow');
});
});
PROBLEM
On initial load, this works perfectly, as intended. However, as soon as I click a category and the filtered results show up in the content box, the accordion no longer works and even my console.log
fails. None of the classes change after the results have loaded.
QUESTION
Is there any way the Ajax loading could be disabling the ability to use jQuery to target elements as in the code above?