Skip Navigation

[Resolved] Javascript to reload search form

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 6 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

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

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 6 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#551705

I have a post type View that displays its search form as a list of radio buttons (terms). It's for an intranet site which means the terms are dynamic. I.e., the terms can be created or deleted by users. I used ajax to display the search results (posts that belongs to the terms).

Now, similarly, I'd like to use ajax to reload the search form (the radio buttons / terms). Is there any way to achieve this?

By the way, I've already tried the following:

1.) Using "render_view" from the View API, but it doesn't reload the latest terms. For example, if a term is deleted by a user, the render_view function still includes the term from previous filter. Further, the function displays both the search form and results. Since I'm already using ajax to display the results, Im only interested in the search form.

2.) I use jquery to reload a div around the View search form but it ended up returning a blank section.

Thanks.

#551823

Hi, there's not a good way update filter options on-the-fly using AJAX like this in Views. Results can be updated with AJAX, as you have mentioned, but updating the filter options requires a full page reload. Are you concerned that people will have the search form page open for a long period of time, and filter options will be changed frequently during that period of time? Or is there a separate concern? I would like to understand what you want to accomplish to see if there's a different solution available.

#552296

Hi Christian, thanks for replying.

You're right. Since it's an intranet site with hundreds of concurrent users at one time, it's very likely the search options will change. I have ensured that page is reloaded every few seconds for now but its not visually appealing. Any filter hooks I can use for my own ajax function? I looked into wpv_filter_query but it seems to only filter the results. I look forward to your response.

#552546

We offer the following filters you could explore.
1. wpv-view-settings, which allows you to modify View settings, like filter meta html, on-the-fly:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_view_settings

2. wpv-filter-start-filter-form and wpv-filter-end-filter-form, which allow you to prepend or append content to the filter controls:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_start_filter_form
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_end_filter_form

Again, these filters are intended for use with full page reloads so issues arising from using them with AJAX to update filter options on-the-fly will not be supported here in the forum. If you'd like, I can file a feature request to enhance Views with the ability to update filter controls using AJAX. Let me know how you envision this working. For example, is there a refresh button somewhere in the controls that triggers these updates, or a predefined timer refresh, or is it refreshed with any search, etc.

The forum ‘Types Community Support’ is closed to new topics and replies.

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