Tell us what you are trying to do?
I would like a default value selected for a dropdown filter.
E.g. on the below link. I would like "Transnational" to be selected by default / on load.
What is the link to your site?
enlace oculto

Minesh
Colaborador
Idiomas:
Inglés (English )
Zona horaria:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
Can you please check now:
- enlace oculto
I've added the following code to your view's "Search and Pagination" section JS editor:
=> enlace oculto
jQuery(document).ready(function($) {
jQuery("select[name^='wpv-country'] option[value='transnational']").attr("selected","selected").trigger('change');;
});
Can you please confirm it works as expected.
Hi Minesh,
generally it works but only is applied after initially all results are shown.
Can it be done such that is is applied on initial load. If not could the loading indicator be shown until it refreshes ?
Thank You

Minesh
Colaborador
Idiomas:
Inglés (English )
Zona horaria:
Asia/Kolkata (GMT+05:30)
Can you please check now: enlace oculto
I've added the following code to "Custom Code" section with code snippet "toolset-custom-code":
- enlace oculto
add_filter('wpv_filter_query', 'wpv_prefilter_with_taxonomy_term', 99, 3);
function wpv_prefilter_with_taxonomy_term ( $query_args, $view_settings, $view_id ) {
if( $view_id == 17009 and ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
$query_args['tax_query'][] = array(
array(
'taxonomy' => 'country',
'field' => 'slug',
'terms' => 'transnational'
)
);
}
return $query_args;
}
Also - I've added the following code to your view's "Search and Pagination" section JS editor:
=> enlace oculto
jQuery(document).ready(function($) {
jQuery("select[name^='wpv-country'] option[value='transnational']").attr("selected","selected");
});
Can you please confirm it works as expected.