Forums › Forums › Search & Filter Pro › Made a new Search and it doesn't works.
- This topic has 27 replies, 2 voices, and was last updated 8 years, 10 months ago by Ross.
-
Ross Moderator(Private) December 28, 2015 at 12:47 pm #32922
Hi Idan
Ok so to answer your questions:
2) yes the code has been designed to work with labels – so styling labels based on checked state is built in. If you want to style the
li
element that the checkbox is contained in then you will need to write some custom javascript to add / remove classes based on whether the checkbox is ticked.Something like (untested, and will need some adaptation, this is just for the general idea):
jQuery(document).on("change", ".searchandfilter .yourfieldclass li input[type='checkbox']", function() { if(jQuery(this).prop("checked")==true) {//then update the background colour jQuery(this).parent().css("background-color", "#f00"); } });
In the code above you will need to update
.yourfieldclass
with the name of the class on the field element.It will likely need some work to do what you want but I think its a decent indication of the direction to take.
3) This again is some custom code that is out of the scope here really.
You would need to detect a click on the LI, and then set any checkbox elements inside to “checked”
jQuery(document).on("click", ".searchandfilter .yourfieldclass li", function(){ //detect a click on an LI element within a specific field. //then set the checked state to true jQuery(this).find("input[type='checkbox']").prop("checked", true); });
You can use the code above as a basis for solving your tasks but its not officially supported within the plugin itself.
Thanks
Ross Moderator(Private) December 29, 2015 at 1:13 am #32953Hi Idan
As mentioned, the above were just examples of the correct approach – I didn’t test the code, merely wrote the logic (and hoped the exact syntax would be correct).
I’m sure its not too far off, but these are things you will need to figure out for you own environment.
If you need JS help there are plenty of resources online which I’m sure you could adapt – eg:
http://stackoverflow.com/questions/10846127/change-parent-div-on-inputtype-checkboxchecked-with-cssI’ll consider to add in some similar functionality in the future.
Thanks
Ross Moderator(Private) January 4, 2016 at 5:15 pm #33268Hey Idan
I’m working on this issue right now
I’ll send you another update once its complete.
Thanks
Ross Moderator(Private) January 6, 2016 at 12:38 am #33443Just sent you a fix, let me know if it works for you!
Thanks
Ross Moderator(Private) January 6, 2016 at 5:56 pm #33491Hi Idan
So the issue here is that your Javascript is not being loaded & applied to the new results that appear.
To resolve this issue you can disable ajax (the easy, not so pleasant way).
Or, better yet, re-initialise your JavaScript once the S&F results are loaded in (this requires some coding knowledge).
Check the first question in the FAQs for an example of how to do detect when S&F has loaded new results: http://www.designsandcode.com/wordpress-plugins/search-filter-pro/faqs/
Thanks!
-
AuthorPosts