Skip Navigation

[Resolved] Change the appearance of the label of filters presented as checkboxes

This thread is resolved. Here is a description of the problem and solution.

Problem:

I'm trying to change the appearance of the labels of the checkboxes that are used to filter the elements of a view.

Solution:

It needs custom JS codes, for example:

https://toolset.com/forums/topic/change-the-appearance-of-the-label-of-filters-presented-as-checkboxes/#post-2213363

Relevant Documentation:

This support ticket is created 3 years ago. 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.

Our next available supporter will start replying to tickets in about 7.16 hours from now. Thank you for your understanding.

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)

This topic contains 6 replies, has 2 voices.

Last updated by dominiqueM-3 3 years ago.

Assisted by: Luo Yang.

Author
Posts
#2211069

Tell us what you are trying to do?
I'm trying to change the appearance of the labels of the checkboxes that are used to filter the elements of a view.

Is there any documentation that you are following?
Several views have been implemented in the site project.
To present the filters for news (hidden link) or events topics (hidden link), I was able to achieve the desired result by following the instructions in this ticket:
https://toolset.com/forums/topic/styling-the-parents-parent-of-checked-checkbox/?utm_source=pocket_mylist
The 'AJAX refresh when changing any filter' and 'Show only filter options that would produce results' options are chosen for these 2 views which only use one set of filters (tags).

On the other hand for another view — hidden link — that I want to filter with 2 sets of filters (specialties and 'obtained the label') and a search field , the proposed script no longer works.

I would like to know if there is a way to have the same rendering for the checkbox labels on the page hidden link as the one obtained on the pages hidden link and hidden link

Thank you

#2211591

Hello,

please try below JS codes:

jQuery( 'input[type="checkbox"].js-wpv-filter-trigger' ).change(function( event, data ) {
  if (jQuery(this).is(':checked')) {
    jQuery(this).parent().parent().addClass('active');
  }else{
  	jQuery(this).parent().parent().removeClass('active');
  }
});

More helps:
hidden link

#2211673

Hi Luo,

Thank you for your reply.

To make sure I didn't make any mistakes, I pasted your script in the 'Custom JS and CSS' area of ​​the 'View' block (the parent block).
Unfortunately the css class 'active' seems to disappear from the <div class="checkbox"> with each AJAX refresh of the search filters.

Regards

#2212405

For AJAX refresh, you need to try the solution in below thread:
https://toolset.com/forums/topic/styling-the-parents-parent-of-checked-checkbox/?utm_source=pocket_mylist

Since it is a custom codes problem, if you need more assistance for it, please provide your website credentials in below private message box, I need to test and debug it in a live website.

#2213363

Thanks for the details, I have changed the JS codes as below:

jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', function( event, data ) {
    /**
    * data.view_unique_id (string) The View unique ID hash
    * data.layout (object) The jQuery object for the View layout wrapper
    */
    jQuery('input[checked=checked]').parent().parent().addClass('active');
     
});

jQuery( document ).on( 'js_event_wpv_parametric_search_form_updated', function( event, data ) {
	/**
	* data.view_unique_id (string) The View unique ID hash
	* data.view_changed_form (object) The jQuery object for the View form after being updated
	* data.view_changed_form_additional_forms_only (object) The jQuery object containing additional forms from other instances of the same View inserted using the [wpv-form-view] shortcode
	* data.view_changed_form_additional_forms_full (object) The jQuery object containing additional forms from other instances of the same View inserted using the [wpv-view] shortcode
	*/
	jQuery('input[checked=checked]').parent().parent().addClass('active');
});

And add a CSS code as below:

div.checkbox.active label{
background-color: blue;
}

Please test again, check if it is what you want, thanks

#2214047

Hi, Luo

This is exactly what I wanted.

Thank you very much

#2214049

My issue is resolved now. Thank you!