-
Search Results
-
Hello,
I am trying to show some custom content on the search and filter results page when a certain filter is selected. Since the results are loaded with AJAX and the page doesn’t refresh, I am trying to do this with Javascript. With JQuery, I am toggling the display of a div when the filter checkbox changes.
$(document).ready(function() { var $e_book_info = $('#e-book-info'); var $input = $('input[value="e-book"]'); if ( $input.is(":checked") ) { console.log('checked'); $e_book_info.show(); } $('input[value="e-book"]').on('change', function() { $e_book_info.toggle(); console.log('toggle switch'); }); });The toggle works when the input is clicked once, but if I try to click it again to toggle back, the function fails to execute, but the AJAX is working fine with Search and Filter. My question is, how can I implement this functionality without the filtering and my function getting in the way of each other? I’m assuming something in the Search and Filter JS is blocking my function from running again.
Thanks for your help!
TravisHi,
I have search and filter pro, it’s a wonderful plugin!
I need to select the filter from the beginning with the value of ‘query var’ from another page.
I’ve done this:
$value = get_query_var('year'); .... <script> $('input[value="<?php echo $value ; ?>"]').click(); </script>But this method is far from ideal because first are charged all items then with click event the filter is activated.
Is there a better method?
Thanks