Skip Navigation

[Résolu] Parametric Views Search Select option on page load

This support ticket is created Il y a 4 années et 7 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

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

Dernière mise à jour par Minesh Il y a 4 années et 7 mois.

Assisté par: Minesh.

Auteur
Publications
#1597941

I'm actually very surprised this isn't a feature build into views, because in a lot of cases it would be required. However I have a view that is a CPT list with a taxonomy filter. On pageload I need to trigger the filter to select the "default" view as you don't have a way to load the page with a default selected(which would be nice) ...

I'm ok writing some JS here just wondering if you can provide me with the function that is being run on a radio button select on a form set to update on ajax so I can trigger that function on pageload to simulate a default being loaded. Using query strings is not an option in this situation.

#1598791

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

You can set the default radio button using the jQuery and trigger the change event on document.ready.

For example:

jQuery(document).ready(function($){
  $('target your radio option using ID or its value').attr('checked', true).trigger('change');
});
#1603033

So I added that which does give the checked status and my styles for the active state are triggered however it doesn't force a reload of the view, which was where I also got to when trying to setup initially.

#1603527

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

We are triggering the .trigger('change') - change event of radio button so it should be automatically triggered. Do you see the filtered posts on your page or you just see that the radio button is checked but the results are not filtered?

#1604577

yes, exactly like you say I "just see that the radio button is checked but the results are not filtered?" You can see the team section here lien caché now, if you see it Appears to be preset on Management, but you have to click off then back on to actually trigger the update of the filter.

#1605521

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Yes I can see that the Management option is selected but it displays all results.

Can I have temporary admin access details so I can check whats going wrong with your setup.

I have set the next reply to private which means only you and I have access to it.

#1606837

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Can you please check now: lien caché

I've added the following JS code to your view's "Search and Pagination" section JS box:

jQuery(document).ready(function($){
   $('input[value="management"]').prop('checked', true).trigger("change");
});

I can see this is working as expected. Can you please confirm it works at your end as well.