Skip Navigation

[Resolved] Grid View loses ajax functionality after selecting filter

This thread is resolved. Here is a description of the problem and solution.

Problem:
Client had some custom JavaScript code that needed to be triggered once more after the AJAX Views search.

Solution:
Using Views JavaScript events. The code below below must be pasted in the JS section of the View:

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
    */
    viba_portfolio.init();
});

You can find all available JS events editing your View and scrolling to the Filter section. There is a button called frontend events.

This support ticket is created 8 years ago. There's a good chance that you are reading advice that it now obsolete.

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.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 -
- - - - - - -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by GeorgeM4735 8 years ago.

Assisted by: Adriano.

Author
Posts
#378888
one-result.jpg

I have created a grid View that uses an isotope effect to relayout items when the browser changes. I recreated this View from a portfolio plugin, I copied the generated code and applied it in a View layout. I also filter the View by 2 taxonomy filters (Categories, Tags) and I have selected the option for the View to udpate results when a user input changes. When the View loads everything looks fine but when I filter with certain category the View only shows one result and any ajax functionality seems to have stopped, for instance a modal window should have opened when clicked on the title of a View item but instead it opens on a separate window. Also the reset button does not work, I need to click the menu link to go back and refresh the View for everything to work again.

It seems to be an issue with the Ajax funtionality when updating the View results after the filtering because it works fine when I select the filters to completely refresh the page and show the results afterwords. I don't see anything in the browser console either.

I have found two threads that might help you:
https://toolset.com/forums/topic/ajax/
https://toolset.com/forums/topic/need-ajax-callback-for-updating-results-when-filters-change/

I am happy to provide a test site, I would have done it here but there is no way to include a private reply in my post, maybe something for the support team to consider in the future?

#378907

I think this is pretty easy to solve. We do have some JS callback that can be used to run your custom JS after the applying the filter, for instance.

I need to request temporary access (wp-admin and FTP) to your site in order to be offering better help. You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

Also, provide the piece of code that you need to run.

#379271

As I promised, quickly fixed by adding the JS below in the View:

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
	*/
	viba_portfolio.init();
});
#379289

That's great man, thank you! Two things:

When I select a portfolio category filter it show the last item by itself for a fraction of a second before it dusplays the filtered results. Same thing when the view first loads. Also after a category filter when I click on a title and the modal pops up then click on the next arrow, there is some kind of weird refresh issue where it either shows the wrong post or it skips through the posts and shows a random one, kind of hard to explain. Just click on a post title and try skipping through the posts through the arrow. It works fine before the filter occurs.

Can we do anything about those issues?

Thanks again!

#379633

Unfortunately I don't know what to do in this case, since this is coming from the main.js file. Even when you remove the line I've added viba_portfolio.init(); in the JS section of the View, you will notice that some element loads by default before showing the other items. The best thing is to contact the developer responsible.

Please let me know if you are satisfied with my reply and any other questions you may have.

Regards,

Adriano Ferreira

#379678

I will do that, thanks for your help!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.