Skip Navigation

[Resolved] Refresh a view via javascript

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

Problem:
The user would like to refresh a view with AJAX.

Solution:
You can use the following function, but it will reload the whole page:

// replace 71 with your view ID
WPViews.view_pagination.trigger_pagination(71, 1)

I suggest you do the following:

      Implement a search form in the view. The search will have at least, a search box and a submit button.
      Configure the views to use AJAX for search results refresh.
      Hide the search form with CSS.
      Call the submit buttons for the views that you want to refresh:

      jQuery('#my-submit-button').click();
      
This support ticket is created 4 years, 2 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
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 4 replies, has 2 voices.

Last updated by Dan Kitsmiller 4 years, 2 months ago.

Assisted by: Jamal.

Author
Posts
#1760655

I have a page that loads two views, and the user can switch between the two via javascript buttons that show or hide them. I need to be able to refresh one of the views on demand. I see a previous post that suggests using pagination controls to reload a view, but I'm not able to get it to work. This is the code:

Refresh

My question is, does the target view need to have pagination set up a certain way for this to function? Are there any other methods to refresh a view without reloading the page?

#1760993

Hello and thank you for contacting the Toolset support.

The function in the sample code has been removed from Toolset Views. You can use the following function, but it will reload the whole page:

// replace 71 with your view ID
WPViews.view_pagination.trigger_pagination(71, 1)

I suggest you do the following:
- Implement a search form in both views. The search will have at least, a search box and a submit button.
- Configure the views to use AJAX for search results refresh.
- Hide the search form with CSS.
- Call the submit buttons for the views that you want to refresh:

jQuery('#my-submit-button').click();

I hope this helps. Let me know if you have any questions.

#1763741

Hi Jamal, I tried your suggestion, but although the view does reload via ajax, it is still not displaying the correct posts. The view I am trying to refresh queries post IDs set by a shortcode attribute, using code that another member of your support team gave me. That support ticket is here: https://toolset.com/forums/topic/conditional-display-posts-based-on-custom-user-meta/

Here is a link to the page: hidden link

I have left the search forms visible for now. My goal is to enable the user to switch between the two views without leaving the page, so they don't need to select a price range every time they view the list. If you would like access to the site, just let me know and I will do a quick backup and send you a login. Thanks!

New threads created by Jamal and linked to this one are listed below:

https://toolset.com/forums/topic/view-not-returning-the-correct-results/

#1764383

For support rules, we are able to handle only one issue at the time. This helps us to bring you a better service and also helps other users to find all the information here exposed. For that reason, I have created another ticket and I'll be posting my replies there.

If you think that the original question of this ticket is answered, please mark it as resolved.

#1765641

My issue is resolved now. Thank you!