Skip Navigation

[Résolu] Bootstrap radio buttons with Ajax

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
Bootstrap radio buttons with Ajax

Solution:
When you visit view's "Search and Pagination" section's JS box - you will see a button "Frontend Events". When you click it it will allow you to choose ajax callback events.

You can find the proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/bootstrap-radio-buttons-with-ajax/#post-1205315

Relevant Documentation:

This support ticket is created Il y a 5 années et 2 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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

Marqué : ,

This topic contains 2 réponses, has 2 voix.

Last updated by katjaL Il y a 5 années et 2 mois.

Assisted by: Minesh.

Auteur
Publications
#1205099

I want to show Ajax radio button filtered search as Bootstrap buttons and active button should look a bit different. (Radio buttons are so 90's somehow, don't you think? That's why I wonder a little why it is so hard to show the buttons more modern way.)

Now I found this thread concerning CRED: https://toolset.com/forums/topic/bootstrap-radio-buttons/ and I've adjusted the code to my view with filtered search.

I'm almost there, but not quite 🙂 I need to add class .active to the chosen button and now when I choose a value it filters ok, and adds the .active class after "submit" ("Full page refresh when visitors click on the search button with input values auto-updating"), but not with Ajax ("AJAX results update when visitors change any filter values") .

At the moment I have this css:

.bootstrap-radio div {
font-size:30px;padding:0 15px 0 0px;margin-right:10px;
display:inline-block;background-color: #17984b;color:#fff;
border-radius:4px;
border:1px solid #fff;
cursor:pointer;
list-style:none;
}
.bootstrap-radio div input {display:none;}
.radio.active {background-color:#e77a6b;}

And this js

jQuery(document).ready(function( $ ){
$('.bootstrap-radio').find('input:checked').parents('div').addClass("active");
$('.bootstrap-radio').find('div').on('click',function(){
$('.bootstrap-radio').find('div').removeClass('active');
$(this).addClass('active');
});
});

#1205315

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

When you visit view's "Search and Pagination" section's JS box - you will see a button "Frontend Events". When you click it it will allow you to choose ajax callback events.

Refer this image:
=> hidden link

For example:

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('.bootstrap-radio').find('input:checked').parents('div').addClass("active");
jQuery('.bootstrap-radio').find('div').on('click',function(){
jQuery('.bootstrap-radio').find('div').removeClass('active');
jQuery(this).addClass('active');
       
});

What if you try to adjust the JS code you shared within this event and check if that help you to resolve your issue.

#1205327

My issue is resolved now. Thank you! For the reference the final js is this:

jQuery( document ).on( 'js_event_wpv_parametric_search_form_updated', function( event, data ) {
$('.bootstrap-radio').find('input:checked').parents('div').addClass("active");
$('.bootstrap-radio').find('div').on('click',function(){
$('.bootstrap-radio').find('div').removeClass('active');
$(this).addClass('active');
});
});

jQuery(document).ready(function( $ ){
$('.bootstrap-radio').find('input:checked').parents('div').addClass("active");
$('.bootstrap-radio').find('div').on('click',function(){
$('.bootstrap-radio').find('div').removeClass('active');
$(this).addClass('active');
});
});

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