Tell us what you are trying to do? I'm trying to filter a view by using specific taxonomy terms output by a different view. This I've accomplished, but as a next step, I'm trying to have the filter view reload the results of the other view by triggering the AJAX rather than reloading the page.
Is there any documentation that you are following? I was referring to this support thread, to see if I could trigger the AJAX refresh without reloading the page, but was unsuccessful at implementing the trigger.
What is the link to your site? lien caché
I've put together a taxonomy view that outputs terms which have no parent, thus controlling what terms would display for the filter controls, as we intend on using sub category terms to identify specific departments that the posts were going to be associated with. The subcategories are intended more for visuals rather than functionality.
My first thought was to output the terms as list items with anchors with the href attribute populated with the necessary URL parameters to filter the view results:
<ul id="portfolio-depts" class="proxima-nova">
<!-- wpv-loop-start -->
<wpv-loop>
<li><a href="?wpv-department=[wpv-taxonomy-slug]&wpv_aux_current_post_id=5134&wpv_aux_parent_post_id=5134&wpv_view_count=954">[wpv-taxonomy-title]</a></li>
</wpv-loop>
<!-- wpv-loop-end -->
</ul>
This works, if the page is reloaded, but my goal with this was to reload the view results by triggering the AJAX, instead of reloading the page. So I was trying to utilize jQuery's preventDefault(); to prevent the page from reloading, and add the href attribute values into the address bar, as seen below:
var portfolioDept = '#portfolio-depts li a';
$(portfolioDept).click(
function(e){
var href = $(this).attr('href');
e.preventDefault();
$(portfolioDept).removeClass('active');
$(this).addClass('active');
window.history.replaceState(null, null, href);
}
);
What I can't figure out is how to trigger the AJAX. The support thread that I'm referring mentions two variables that need to be adjusted in order for a trigger to happen. I get the view_number, but I don't know what "fil" is supposed to represent.
When I dead-ended on that, I tried to replicate the exact form markup from the radio filter controls I generated with Toolset's filter shortcodes:
<form id="portfolio-depts" autocomplete="off" name="wpv-filter-954" action="/our-work/?wpv_view_count=954" method="get" class="proxima-nova wpv-filter-form js-wpv-filter-form js-wpv-filter-form-954 js-wpv-form-full js-wpv-dps-enabled js-wpv-ajax-results-enabled" data-viewnumber="954" data-viewid="954" data-viewhash="eyJuYW1lIjoicG9ydGZvbGlvLWZlZWQifQ==" data-viewwidgetid="0" data-parametric="{"query":"normal","id":"954","view_id":"954","widget_id":0,"view_hash":"954","action":"\/our-work\/?wpv_view_count=954","sort":{"orderby":"","order":"","orderby_as":"","orderby_second":"","order_second":""},"orderby":"","order":"","orderby_as":"","orderby_second":"","order_second":"","ajax_form":"","ajax_results":"","effect":"fade","prebefore":"","before":"","after":"","attributes":[],"environment":{"current_post_id":5134,"parent_post_id":5134,"parent_term_id":0,"parent_user_id":0,"archive":{"type":"","name":"","data":[]}},"loop":{"type":"","name":"","data":[],"id":0}}">
<input type="hidden" class="js-wpv-dps-filter-data js-wpv-filter-data-for-this-form" data-action="/our-work/?wpv_view_count=954" data-page="1" data-ajax="enable" data-effect="fade" data-maxpages="0" data-ajaxprebefore="" data-ajaxbefore="" data-ajaxafter="">
<input class="wpv_view_count wpv_view_count-954" type="hidden" name="wpv_view_count" value="954">
<!-- wpv-loop-start -->
<wpv-loop>
<label for="department-[wpv-taxonomy-slug]" class="transition">
<input id="department-[wpv-taxonomy-slug]" class="js-wpv-filter-trigger" type="radio" name="wpv-department" value="[wpv-taxonomy-slug]">
[wpv-taxonomy-title]
</label>
</wpv-loop>
<!-- wpv-loop-end -->
</form>
It triggers the AJAX, but it changes my filter view to the actual filter controls, which presents undesirable behavior.
So my focus with this inquiry is to see which method is the best way to handle my current problem, which is to filter the view results by triggering the AJAX.
I have a Duplicator package prepared in case you would like access to my site, but asking for help doesn't allow me to add private data to this message.