Tell us what you are trying to do?
Hi! I have a grid of posts which are searchable with a search bar and filter. I'd like to include the reset filter button only when search results or a filtered view is being displayed, I was wondering if there is some jquery which could help?
Thanks!
I don't think there is jQuery required for this (and we could not help with such custom code here neither).
Instead it should be possible to wrap the reset button (or any other item in the View you want to show conditionally) into a so called "HTML Condition".
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
Basically you would listen to (any) search parameter, and if not empty, display the reset button.
Since you never will know what precise parameter will be used, I suggest to check upon the URL queries that always are there in a View:
wpv_filter_submit or wpv_view_count
So your condition could look like this:
[wpv-conditional if="( '[wpv-search-term param="wpv_filter_submit"]' ne '' )"][wpv-filter-reset output="bootstrap"][/wpv-conditional]
I have set this up using the Toolset Guided User Interface, first inserting the [wpv-filter-reset output="bootstrap"], then wrapping that in a conditional output, and editing this later to insert the [wpv-search-term param="wpv_filter_submit"] listener
That will now display my reset button only if I actually searched by something (no matter what) in the View (pressed submit button, basically), because only then the wpv_filter_submit or wpv_view_count are present in the URL.
Does that help to reach your goal?