We discuss this earlier in https://toolset.com/forums/topic/viewfilter-toggeling/ - after update to 3.4.7 the solutions doesnt work anymore. Can you give an hint about changes?
To better assist you with this, I need to take a closer look at the view. Would you allow me temporary access to your website as an administrator? Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **
I think that the issue happens after WordPress update, which included a new version of jQuery. For some reason, the "ready" event on "document" did not fire, and the code was not run.
I updated the code as follows and it fixes the issue:
function handleAccordion($){
$( ".toggle_container" ).hide();
$( "h3.toggle-trigger" ).click( function() {
$(this).toggleClass( "active" ).next().slideToggle( "normal" );
return false;
} );
}
jQuery( function( $ ) {
handleAccordion($);
$( document ).on('js_event_wpv_parametric_search_results_updated', function() {
handleAccordion($);
} );
} );
Great, really - but i have still an issue: After firering the filter, the filters don't stay open. In the past we solved the problem; but now i can't find the specific function. Can you help again?
Of course, I don't really remember or find how we did it last time, but I was able to add a couple of lines to handle this, the whole code is now like this:
jQuery( document ).on( 'js_event_wpv_parametric_search_triggered', function( event, data ) {
/**
* data.view_unique_id (string) The View unique ID hash
* data.form (object) The jQuery object for the View form
* data.update_form (bool) Whether the custom search form will be updated
* data.update_results (bool) Whether the custom search results will be updated
*/
jQuery('html, body').animate({ scrollTop: 0 }, 600, 'swing');
});
function handleAccordion($){
// close all accordions
$( ".toggle_container" ).hide();
// open/close accordion on click
$( "h3.toggle-trigger" ).click( function() {
$(this).toggleClass( "active" ).next().slideToggle( "normal" );
return false;
} );
// open accordions that have an option selected
setTimeout(function(){
$('.toggle_container').each(function(){
var $this = $(this);
var checkboxes = $this.find('input[type="checkbox"]:checked');
if ( checkboxes.length ) $this.slideToggle( "normal" ).prev().addClass('active');
});
}, 0);
}
jQuery( function( $ ) {
handleAccordion($);
$( document ).on('js_event_wpv_parametric_search_results_updated', function() {
handleAccordion($);
} );
} );
I tested it and It works as expected. Can you check again from your side?
Unfortunately, unfortunately, I cannot confirm that it works. The filtering now works correctly, but when I select a filter by clicking on it, the filters close again. So I don't see what I've already chosen.
I don't get that. Maybe you just need to hard refresh the page. Check this screencast, after filtering, the checked filters' accordions are opened automatically hidden link
If the screencast is not working for you, it is still being processed by Google, just wait a few minutes.
Can you tell me the exact steps you do and what outcome you get:
1. I choose xxx in xxx.
2. I expect to have xxx
3. Instead I get xxx
It would be very helpful if you record a screencast using Loom or Screencastify.
My issue is resolved now. Thanks a lot - i think i have an cache-thing on my side ... 🙂