Skip Navigation

[Resolved] Custom Search: filter (select-option) only filters first ajax page

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: Asia/Karachi (GMT+05:00)

This topic contains 6 replies, has 2 voices.

Last updated by Waqar 10 months, 3 weeks ago.

Assisted by: Waqar.

Author
Posts
#2678353

a.R

On our start page "Aktuelle Meldungen" should be filtered by "Klasse" above, but after first ajax page, ALL posts will appear!
We´ve just built that view from scratch, and it´s quite simple.

#2678413

Hi,

Thank you for contacting us and I'd be happy to assist.

From the description, it looks like the 'Aktuelle Meldungen' is a taxonomy and by default, you'd like the results to be filtered by its term 'Klasse'.

Have you added a fixed/static query filter for this taxonomy or a front-end search field/filter?
(it's important to note that a front-end search field will always override the static query filter )

You're welcome to share temporary admin login details, along with the exact steps to see this challenge that you're having.

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

regards,
Waqar

#2678440

a.R

Meldungen is a term (in the taxonomy 'Beitragsarten'), that is fixed in that ViEW.

Klassen is a taxonomy that is set by a select-option-field (above the view results), that is manipulated by jquery.
(We didn´t just use checkboxes there, to prevent too many elements with the same ID. - Will a VIEWS filter still work after manipulating the INPUT IDs by jquery, or is that a bad idea? Or is it no problem to have multiple elements with same IDs there?)

#2678446

a.R

I mean, we have 3 VIEWS on our start page, that can be filtered by "Klassen(stufen)", so we have the same IDs (in that Klassen-terms-checkboxes) multiple times...

#2678740

Thanks for writing back.

> Klassen is a taxonomy that is set by a select-option-field (above the view results), that is manipulated by jquery.
(We didn´t just use checkboxes there, to prevent too many elements with the same ID. - Will a VIEWS filter still work after manipulating the INPUT IDs by jquery, or is that a bad idea? Or is it no problem to have multiple elements with same IDs there?)

- Having multiple elements with the same IDs is not recommended, because it makes the markup invalid. Most browsers also tend to automatically append the repeated instances of the IDs with numeric combinations, like "-1", "-2" etc.

Even if you need multiple instances of search filters in multiple instances of the views on a page, most of the time, having the same URL parameter as a listener is enough. You don't need to use the same IDs.

When the view(s) are set to update the results, using AJAX and without a page refresh, it becomes challenging though.

Can you share the link to the starting page that you're working with, along with the details of the challenge that you're facing? I'll be in a better position to suggest the next steps, accordingly.

#2680365

a.R

Thank you, Waqar.

It´s on our start page, hidden link.
There, "Aktuelle Meldungen" should be filtered by "Klasse" from the VIEW above.
(Now we removed the "Klasse" filter from "Aktuelle Meldungen", as it was not working properly.)

Or maybe, can we somehow just make the "Aktuelle Meldungen" VIEW automatically use the URL-parameters of the "Was magst du heute entdecken?" VIEW above? The "Klasse" filter (ideally ALL filters) should affect both views. That would be so nice!

#2680766

Thank you for waiting, while I performed some tests on my website.

Based on what we've discussed here are a few options which can be adopted:

1. No 'AJAX' approach:

If you'd like to use the same URL parameters/search filters across multiple views, the safest approach would be to set the views not to use AJAX and update the results, through page reload.

As a result, whenever the page refreshes to update the results, the updated URL parameter values will be picked up by all the views used on the page.

OR

2. Custom script approach:

If the 'AJAX' refresh feature is important, another alternative can be to create the search filters for each view, as you would when used alone as a single view.

When those views are added to a page, you can use custom CSS code to hide the repeating or unwanted search field filters, keeping only a single search form available for user interaction.

Next, the custom script can be added to detect changes in the filters/fields available in the visible search form and then trigger them on the corresponding hidden search filters/fields too. This way AJAX will be fired on the other views too, making them update the results.

I hope this makes sense and let me know if you have any follow-up questions.