Tell us what you are trying to do?
This site has a database of keys that are returned using a toolset view search and filters.
The filters return results based on options already selected.
We are looking for a way to render results when a search is submitted but also reset all the filters.
We assume we would need to use a custom JS function to do this.
What could we target to set up this JS?
You want users to choose filter options, which return filtered results.
But the filter controls shouldn't retain the previous selection, they should revert to the default state.
(You are not talking about adding a Reset button to clear the filters and reload the unfiltered results.)
When a user submits filter choices the content reloads and shows the filter controls with their selections and the filtered results. The filter control selections are specified in the delivered markup, rather than being applied by JS.
So if you are using page reload when users submit the filters you should just be able to use the document load event to run JS which updates each of the filter controls as required.
If you are using ajax you can use the custom event 'js_event_wpv_parametric_search_results_updated'.
(If you are using the classic Views editor, where you insert custom JS the "Frontend events" button will generate placeholder code for the various custom events that are available, see screenshot.)
Thank you for your response. You are correct in your assessment however we are using 'js_event_wpv_parametric_search_results_updated' to trigger the clearing of the search filters when a search is done. While it does clear the filters, because there are several filters dependent upon each other (as in you cannot select options from Filter 2 unless those options are included in Filter 1's selection), after a search is done the filters only show options from the previous search and not all filter options.
As Nigel stated - you will have to use the non-AJAX and see if you achieve what you are looking for. If you are using dependent filters there is no way to manage those filters using ajax.
However - if you can tell me what filters you have set as dependent filters and share problem URL and admin access details I will review your current setup and check if I can share any workaround.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
In your case you are using custom field as year, make, model and you added custom JS code to filter those results. We are offer limited support on such custom edits as per our support policy.
If you want to keep that custom code and need help in extending that - I suggest you should get in touch with any of our certified partners who will help you with your any custom programming requirements.
- https://toolset.com/contractors/