Skip Navigation

[Résolu] Javascript loading in ajax view

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Marqué : 

This topic contains 4 réponses, has 3 voix.

Last updated by Dido Il y a 11 mois et 3 semaines.

Assigned support staff: Minesh.

Auteur
Publications
#1818159

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?

#1819105

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+01:00)

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.

#1824865

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.

#1825087

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

#1827901

My issue is resolved now. Thank you!