Navigation überspringen

[Gelöst] Views: Pre-select checkbox in custom search

This support ticket is created vor 5 Jahren, 5 Monaten. 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.

Dieses Thema enthält 1 Antwort, hat 1 Stimme.

Zuletzt aktualisiert von webD-3 vor 5 Jahren, 5 Monaten.

Author
Artikel
#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.