Skip Navigation

[Resolved] View Filter toggeling

This support ticket is created 3 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 7 replies, has 2 voices.

Last updated by Florian 3 years, 11 months ago.

Assisted by: Jamal.

Author
Posts
#1948939

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?

#1949083

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. **

#1949327

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($);
  } );
} );
#1949541

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?

#1951281

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?

#1951337

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.

#1951409

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.

#1951651

My issue is resolved now. Thanks a lot - i think i have an cache-thing on my side ... 🙂