Skip Navigation

[Resolved] Ajax won't show search results from a selector

This support ticket is created 5 years, 11 months 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by Mario Hernandez 5 years, 10 months ago.

Assisted by: Nigel.

Author
Posts
#1192457
Captura de pantalla 2019-01-29 a las 10.53.48.png

hi!

here: hidden link you can find a directory with a filter at the right. When you select "Filtrer par" and change the value, the page won't show the results until you click on "Je Trouve" at the bottom.

As you see in the photo, I had to select "pagination enabled with manual transition and page reload because with AJAX the page won't return to the top of the page, and we need also that when the user clicks on "next page", he is guided to the top of the page. That's why I force a page reload. I would be very grateful if you help me also to make this AJAX transition possible WITH a return to the top of the page.

Thank you very much,

Mario

#1192544

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

Screenshot 2019-01-29 at 11.29.51.png

Hi Mario

Your wish is to use ajax pagination and ajax for any filters, and automatically scroll back to the top of the page when the results update, is that correct?

Views fires some custom JS events (which you can insert using the Front-end events button in the custom JS section, as shown in the screenshot).

Here is an example of the code you would use to scroll to top after paginating:

jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
  jQuery("html, body").animate( {scrollTop: 0}, "fast");
});

And you would add something very similar for scrolling to top after custom search results update via ajax:

jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', function( event, data ) {
  jQuery("html, body").animate( {scrollTop: 0}, "fast");
});

Is that what you had in mind?

#1195391

Thank you Nigel!

I just added those two snippets of code in the"Search and Pagination" JS Editor field and worked seamlessly,

have a great day!

Mario