dynamic ("dependent") checkboxes in search results filter
what would it take to build dynamic/"dependent" checkboxes to filter search results?
my client has a listing of jobs from different countries and cities around the world.
when someone searches, they want the user to be able to select a country, and then the "cities" list would get filtered down to show only cities of the selected country.
of course, both the list of countries and the list of cities will be populated from the entries for each city.
I've implemented the search results filter feature of low search before but wonder how complex it would be to add the above feature.
thanks.
Replies
Low 9 Jan 2014 09:28
This probably is the only aspect that is an issue, specifically with paginated search results. Currently, there's no way for me to get a list of *all* entry IDs that are part of a result set. Therefore, it's not possible to generate filter parameters based on that result set either. It's a restriction in EE's current API.
The rest should be doable outside of Low Search. Probably just a matter of two drop down elements and some JavaScript to show/hide different <option>s in one <select> based on the value of the other.
pirco 9 Jan 2014 19:03
thanks, low!
yea, I'm familiar with the javascript to show/hide different s and es. so the tricky part is to populate those checkboxes only with values related to the found search results.
would it be possible to use jQuery to read all the entry IDs of the result set into a javascript array?
then I should be able to limit the checkboxes based on that array.
but... hmm. having the entry ID in javascript doesn't really get me the category values for the checkboxes, does it?
Low 10 Jan 2014 08:44
As I said, it's not possible for me to get all entry IDs of a result set for paginated entries.
For non-paginated entries, you could set a property like data-collection="{low_search_collection_id}" to each result. Then read those with JS and show/hide the collection-list you generated elsewhere on the page accordingly. Make sense?
pirco 10 Jan 2014 17:14
sorry, it didn't sink in the first time around.
it is really more of a filter functionality anyway.
thanks!