I'm using a very simple javascript (I plan to expand on it) that's attached to a 'view' for an archive list of custom Post Type that has taxonomies and categories that I wish to use for sorting.
I would like to use Ajax to update the sorting process, however I've discover that it won't refire after the Ajax update.
How can I get around it? Would it make a difference if it was written in JQuery. What about the 'frontend event handler'?
I've looked everywhere for an explanation & workaround.
You can see what I'm doing at -- hidden link
Hi, there is a button in the Search and Pagination JS panel that lets you hook into specific search and pagination events. See the attached screenshot. If you cannot see the Search and Pagination panel in the View editor screen, scroll to the top right corner and click "Screen Options". You can activate the Search and Pagination panel here. Then in the JS panel beneath it click "Frontend events" and choose "Custom Search" then "The custom search results have been updated". This will insert a jQuery event listener hook for you, and you can call some custom JavaScript function from within that hook. For example:
function myfunction( viewid ) {
alert('View ' + viewid + ' has been 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
*/
myfunction( data.view_unique_id);
});
It's best to use the namespace jQuery instead of $ to access the jQuery object with Toolset.