Hi,
I've spent many hours trying to figure it out without success... It is easy to do if I don't bother refreshing the page, but that's not what I want, so then it gets complicated...
I have three Views:
1- The first one that lists all the job postings' title and I have used some html to create a link with the id, as you mentioned (<a href="[wpv-post-id]" class="btnPostes">[wpv-post-title]</a>)
2- The second one displays 1 result (to be sure when the page first loads) and uses the filter id by url; in it, I show the title and body of the custom type;
3- An "overall" View where I use the first View as the filter (can we really do it? It shows the "Fields and Views" button, but when we add it, it doesn't create any Query Filter like a "regular" filter would do) and the second View above the loop (inside [wpv-items-found], because if I don't do that, it loads the first element five times...)
The third View is set to use a filter; the Custom Search Settings is set to "AJAX results update when visitors change any filter values).
If I leave it like that, it does work, but always reloads the page (well, actually, if I put the full url; if not, it just tried to load the sitename/id) and end up on a 404 page...
So, I added <input type="hidden" name="post_ids" id="post_ids"> in the Search and Pagination section and this code in the JS section (on the filter) (the first level function is just to be able to use "$" instead of always typing "jQuery"):
(function($) {
$('.btnPostes').click(function (event){
event.preventDefault(); // needed, or the page always loads the full page, i.e. no AJAX call but the entire page is reloaded
$('#post_ids').val($(this).attr('href')); // adds the id to the hidden field
$(document).submit();
});
})( jQuery );
That doesn't work... I tried adding some code to see if the event is triggered:
jQuery( document ).on( 'js_event_wpv_parametric_search_triggered', function( event, data ) {
/**
* data.view_unique_id (string) The View unique ID hash
* data.form (object) The jQuery object for the View form
* data.update_form (bool) Whether the custom search form will be updated
* data.update_results (bool) Whether the custom search results will be updated
*/
alert('triggered');
});
jQuery( document ).on( 'js_event_wpv_parametric_search_started', function( event, data ) {
/**
* data.view_unique_id (string) The View unique ID hash
*/
alert('started');
});
jQuery( document ).on( 'js_event_wpv_parametric_search_form_updated', function( event, data ) {
/**
* data.view_unique_id (string) The View unique ID hash
* data.view_changed_form (object) The jQuery object for the View form after being updated
* data.view_changed_form_additional_forms_only (object) The jQuery object containing additional forms from other instances of the same View inserted using the [wpv-form-view] shortcode
* data.view_changed_form_additional_forms_full (object) The jQuery object containing additional forms from other instances of the same View inserted using the [wpv-view] shortcode
*/
alert('search form updated');
});
jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', function( event, data ) {
/**
* data.view_unique_id (string) The View unique ID hash
* data.layout (object) The jQuery object for the View layout wrapper
*/
alert('results updated');
});
Nothing is triggered... Even if I try to add another component like a drop-down, the trigger event is raised, but not the others...
Since when we add a "regular" filter, it aslo add some code to the "Query Filter", I tried adding the post_ids URL parameter, but it still didn't work.
Since there is not <form> tag added to the filter, I changed my code (for the hidden input) to:
<form id="postes">
<input type="hidden" name="post_ids" id="post_ids">
</form>
And then used $('#postes').submit(); instead of the document... Again, it works, but reloads the entire page (so defeats the whole purpose of those manipulations)...
So, my guess is that I'm trying to use a View as the filter, but I don't really have the choice to be able to use the post name as my buttons...
Can you help me on that?
Thank you.