- This topic has 3 replies, 2 voices, and was last updated 8 years, 1 month ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
These forums are now closed and remain for historical purposes.
None of the content applies to the new version 3. For support, get in touch via our contact form.
Forums › Forums › Search & Filter Pro › How to stop removal of JS classes on Ajax change?
Hello,
I’ve implemented some JS code to the H4 headings of each section within the UI so that you can toggle each one to reveal the different checkbox options (otherwise it would be a really long list).
On clicking the H4, it adds an open class to the ul that contains the checkbox options, which I can then hook onto in CSS to show the options. However after selecting an option, the refreshing of results via AJAX removes this open class that has been added.
How do I stop this class from being removed? It seems like on Ajax refresh there is some sort of function that refreshes all of the search and filter UI markup, as well as the results. Alternatively, is there a JF function I can hook into to trigger after this completes?
If you turn your code into a function, and call that function on page load, then, use this code also (inserting you function into the commented out line:
<script>(function ( $ ) {
"use strict";
$(document).on("sf:ajaxfinish", ".searchandfilter", function(){
console.log("ajax complete");
// load your code function here
});
}(jQuery));</script>