Forums › Forums › Search & Filter Pro › to possible? + Showing when filter is active
- This topic has 9 replies, 2 voices, and was last updated 7 years, 9 months ago by Trevor.
-
Anonymous(Private) February 2, 2017 at 4:49 pm #87632
Is there a way for me to change the select/list options to render as a ul element for advanced styling? I want to style the drop downs similar to a faux dropdown like bootstrap does. Also is there a way to add a class/attribute to the filter when it is active/filtering and remove it when the filter is “empty”, like some specific event I can hook into with javascript?
Trevor(Private) February 2, 2017 at 7:00 pm #87684I think this reply to a different thread might be applicable to this thread:
https://support.searchandfilter.com/forums/topic/split-form-output-single-field/#post-86065
However, I have seen some users style a list of checkboxes so that clicking the title opens and closes the list? I am not sure how they have done it, by custom CSS I should think, and maybe a bit of javascript. Most elements have unique classes and/or ID’s to target.
Or did I miss the point?
I have a feeling a lot more functionality like this will arrive in the next major update, V3.
Anonymous(Private) February 2, 2017 at 7:16 pm #87689I just noticed that the title of the topic was parsed out, it was supposed to say “select to ul possible?” so that might have made it a little confusing.
What I am hoping is to make it so that instead of the filter using the select elements and the code being:
<select name="input_name"><option value="1"><option value="2"><option>
It would render the drop downs as unordered lists so that they could be custom styled. like:
<ul name="input_name"><li>option 1</li><li>option 2</li></ul>
As for the second question, what I meant is so that when the form is submitted/changed by the user I want to append a new class to the filter/elements that shows that its active and remove it when the filter is just showing the default. Is there a specific hook I can use for when the form submits and has values vs when the form clears and returns to default.
Trevor(Private) February 2, 2017 at 7:58 pm #87711As to the first part of the question above, try changing the type of form field to Checkbox or radio and see if that looks closer in terms of the HTML structure. For me it does.
As to the second part, I understand. In your UL example, if that field had a filter selected, it would be the li that has the extra class to show it is selected, but CSS allows you to target the parent of an element that has a given class (in this case it would be the class
sf-option-active
). You can hide the checkbox with custom CSS as well.Our sf_input_object_pre filter allows you to target these inner elements also.
Anonymous(Private) February 2, 2017 at 8:16 pm #87720Ok, I see what you are saying with the checkboxes. For the second one I don’t mean on an individual option. I mean I want to change the DOM based on if the entire filter has run or if it “clear”(showing all options). So as an example. I have the filter surrounded like this:
<div id="filter_holder" class="unactive"> <!-- filter is here --> </div>
And when someone activates an option or multiple options on the filter I want to append a class to surrounding holder like:
<div id="filter_holder" class="active"> <!-- filter is here --> </div>
This way I can show the users with extra css that the filter is narrowing down the results they are seeing.
Trevor(Private) February 2, 2017 at 10:40 pm #87747What I am saying is that you already have is this (a rather simplistic example, not a real example):
<ul id="filter_holder"> <li class="active"></li> <li></li> <li></li> <li></li> </ul>
And you can use CSS to target the parent of the active class; the ul. The active class will only be there if a selection has been made.
This is, in effect, the same as having a class on the outer container.
Anonymous(Private) February 3, 2017 at 5:24 pm #87979When I use the filter and select and option, there is no class that activates anywhere on the filter indicating activation/use. It only disables for a moment and then returns to normal. Also just to let you know that link you sent about the :parent selector is a hypothetical suggestion of css. The first line is there are no parent selectors in CSS.
<br />
But anyway all I want to know is if there is anywhere in the filter functions that goes off when the filter is used/active so that I can trigger other things to happen on the page when the filter isn’t showing “all results”.Trevor(Private) February 3, 2017 at 5:37 pm #87995Have a quick look at this thread as it shows/discusses the use of the ajax detection hooks in our plugin:
You can also use PHP like this to detect an absence of applied filters, see this post:
https://support.searchandfilter.com/forums/topic/force-selection/#post-87657
-
AuthorPosts