Skip Navigation

[Resolved] Filter by tags — stange behavior

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a collapsed panel that contains my custom search filters. When the View is updated, the panel returns to the collapsed state. I would like to keep the panel open.

Solution: Use custom JavaScript and the frontend events hooks to make the panel appear open without animation after the filters are updated automatically.

jQuery( document ).on( 'js_event_wpv_parametric_search_form_updated', function( event, data ) {
    /**
    * data.view_unique_id (string) The View unique ID hash
    * data.view_changed_form (object) The jQuery object for the View form after being updated
    * data.view_changed_form_additional_forms_only (object) The jQuery object containing additional forms from other instances of the same View inserted using the [wpv-form-view] shortcode
    * data.view_changed_form_additional_forms_full (object) The jQuery object containing additional forms from other instances of the same View inserted using the [wpv-view] shortcode
    */
    jQuery('#collapseFilter').addClass('in').css('height','auto');
});

Relevant Documentation:
https://toolset.com/documentation/user-guides/front-page-filters/advanced-settings-custom-search/

This support ticket is created 3 years, 8 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by deanL 3 years, 8 months ago.

Assigned support staff: Christian Cox.

Author
Posts
#1223929
Image 2019-04-01 at 21.32.42.png

Please take a look at this page for example: hidden link — we want to let users filter posts by tags (click the "Filter" link under "Scams in China").

In the view settings, I could only choose either of the following options:
1. Full page refresh when visitors click on the search button with input values auto-updating
2. AJAX results update when visitors click on the search button
3. AJAX results update when visitors change any filter values

Problem is, these are not ideal as the "filter panel" (on the frontend) will not remain open while I change options. In order for the panel to stay open, I have to go with: "Full page refresh when visitors click on the search button". But as soon as I had set that, every single tag is showing in the filter panel (see screenshot).

What have i done wrong?

#1224022

Problem is, these are not ideal as the "filter panel" (on the frontend) will not remain open while I change options.
You can use JavaScript to automatically re-open the panel each time the filters have been updated. There is an event handler just for this purpose. Under the Search and Pagination editor panel, open the JS tab and click "Frontend Events". You can insert an event handler for different custom search events, like:
- The custom search form has been updated

Use these event handlers to toggle the filter panel open without animation.

jQuery( document ).on( 'js_event_wpv_parametric_search_form_updated', function( event, data ) {
	/**
	* data.view_unique_id (string) The View unique ID hash
	* data.view_changed_form (object) The jQuery object for the View form after being updated
	* data.view_changed_form_additional_forms_only (object) The jQuery object containing additional forms from other instances of the same View inserted using the [wpv-form-view] shortcode
	* data.view_changed_form_additional_forms_full (object) The jQuery object containing additional forms from other instances of the same View inserted using the [wpv-view] shortcode
	*/
	jQuery('#collapseFilter').addClass('in').css('height','auto');
});
#1224272

Christian you are amazing!

Silly me didn't think of approaching it from another angle. Instead of trying to stop the auto refresh, I should think about how to stop the panel from collapsing.

Problem solved now!