Skip Navigation

[Resolved] JS after results updated is not working

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

Problem: I have a custom search View that includes several radio buttons. I have used CSS to hide the round radio buttons, but the labels are still shown. I am trying to change the text style when a label is clicked, but as soon as the results update the changes are overwritten.

Solution: Filter customizations are a bit outside the scope of support we provide here in the forums. With that being said, we offer a few other event hooks you can use. When the form updates, you'll have to use JavaScript to inspect the radio buttons. If any button is checked, you must set the corresponding label color to be red. Each time a search is performed, or pagination is changed, the entire search form is replaced in the DOM. So any changes you made before the update must be repeated.

Relevant Documentation:
https://toolset.com/documentation/user-guides/front-page-filters/advanced-settings-custom-search/#automatic-view-update

This support ticket is created 5 years, 10 months 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by pedro.S 5 years, 10 months ago.

Assisted by: Christian Cox.

Author
Posts
#1193892

Tell us what you are trying to do? Since i will hide the filter taxonomy radio buttons, i want to change the color of the label according to the selection made.

Is there any documentation that you are following? no

Is there a similar example that we can see? a WordPress portfolio gallery by default has something like this.

What is the link to your site? I will provide in privacy.

I have a filter set by taxonomy. This taxonomy filter is radio buttons. I will hide the radio buttons so that only the label remains.

Since the radio buttons will dissappear i will need to set some difference to the selection with color or bold.

In the View i created with the search filter, i placed:

jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', function( event, data ) {
/**
* data.view_unique_id (texto) O ID hash único da View
* data.form (objecto) O objecto da jQuery para o formulário da View
* data.update_form (booleano) Se o formulário de pesquisa personalizada será atualizado
* data.update_results (booleano) Se os resultados da pesquisa personalizada serão atualizados
*/
$(".publicacoes-filtros label").click( function() {
$(this).css("color","red");
});
});

In the Search and Pagination box JS.

What happens is that when i click the label, it turns red, but once it updates the results it goes back to the original color. How can i change the label properties onclick without them loosing its properties after the results update?
The results are set to Ajax.

#1193905
Screen Shot 2019-01-31 at 12.28.15 PM.png

Hi, filter customizations are a bit outside the scope of support we provide here in the forums. With that being said, we offer a few other event hooks you can use, as shown in the attached screenshot. When the form updates, you'll have to use JavaScript to inspect the radio buttons. If any button is checked, you must set the corresponding label color to be red. Each time a search is performed, or pagination is changed, the entire search form is replaced in the DOM. So any changes you made before the update must be repeated.

#1194199

Thanks Christian, you didn't handed me the fish but told me how to fish it. Problem Solved 🙂