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?
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.
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!
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.
My issue is resolved now. Thank you!