Sauter la navigation

[Résolu] Preset value of Taxonomy filter dropdown

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:

Is there some event I need to trigger to get Views to update the displayed results?

Solution:

You can try to modify your JS codes as below:

https://toolset.com/forums/topic/preset-value-of-taxonomy-filter-dropdown/#post-1367151

Relevant Documentation:

https://api.jquery.com/trigger/

This support ticket is created Il y a 5 années et 3 mois. 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: Asia/Hong_Kong (GMT+08:00)

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par davidS-53 Il y a 5 années et 3 mois.

Assisté par: Luo Yang.

Auteur
Publications
#1367007

I have a wordpress archive set up with a taxonomy filter select dropdown named "wpv-product-category". When navigating to the page, I want to preset the taxonomy select option to "household". I have the following JQuery added to the JS of the filter section:

jQuery(document).ready(function($) {
jQuery("select[name^='wpv-product-category'] option[value='household']").attr("selected","selected");
});

It changes the select value just fine, but does not update the results on the page. Is there some event I need to trigger to get Views to update the displayed results?

Thanks for your help.

#1367151

Hello,

I assume you are using AJAX search option: AJAX results update when visitors change any filter values
You can try to modify your JS codes as below:

jQuery(document).ready(function($) {
	jQuery("select[name^='wpv-product-category']").val("household");
	jQuery("select[name^='wpv-product-category']").trigger("change");;
});

More help:
lien caché

#1368237

Works a treat, thanks a lot!