Hi,
on this website hidden link
I use a javascript for the masonry sorting. When I click on a filter, the javascript is not loading, because it is in the header.
When I put the script in the view, I got errors. What can I do to solve this?
There is a custom JS event that you can use to add back the masonry code (which is lost when a filter is applied), namely
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
*/
});
You may like to know if you use Blocks (rather than the legacy Views) then a Masonry grid is one of the output options, you wouldn't need a custom solution.
I added the code you provided in the view, but it was not the solution yet.
I will look again to my script. I copied it from the original website, but the maker combined more scripts in one file.
So I will clean it up first.
hidden link is the website I have to remake in WordPress.
Ok - please make sure you do not have any Javascript error with your browser's console and yes, please remove unwanted scripts and let me know if you require further assistance.