Skip Navigation

[Résolu] Views: Pre-select checkbox in custom search

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

This topic contains 1 réponse, has 1 voix.

Last updated by webD-3 Il y a 4 années et 7 mois.

Auteur
Publications
#1338187

My view is using Custom Search with a taxonomy filter.

I would like to pre-select one of the five taxonomies when the page is originally loaded.

In the JS editor for Search and Pagination I've added the following:

jQuery("#channel-group-group-none").prop("checked", true);

When the page is originally loaded the box is checked, but the output is not filtered.

Once one clicks on another checkbox, however, the filter is applied and both checkboxes are honored by the filter.

I tried using the options in "Frontend events" but none of them allow me to pre-filter the view upon the initial page load. Is there a way that I can have the initial page load show only the posts that match channel-group-group-none ?

#1338219

I believe I solved my own issue. This seems to work:

jQuery(document).ready(function(){
jQuery("#channel-group-group-none").click();
});

Perhaps making "jQuery(document).ready(function()" available in the "Frontend events" options would be beneficial.

Separately I learned I needed to use .click() instead of .prop("checked", true); in order to actually have the filter applied.

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