Skip Navigation

[Resolved] Setting checkbox with .prop('checked', true) doesn't fire Conditional Group

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.

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/Karachi (GMT+05:00)

This topic contains 3 replies, has 2 voices.

Last updated by Fatih 3 years ago.

Assisted by: Waqar.

Author
Posts
#2249357

I have several Checkboxes for Conditional Groups in my Cred Post Form like this:

 [cred_field field='angaben-zu-starken' force_type='field' class='form-check-input' output='bootstrap']

[cred_show_group if="( $(angaben-zu-starken) eq 'ja' )" mode="fade-slide"]
a lot of important fields ....
[/cred_show_group]

I needed to setup a bootstrap modal confirm for unchecking the checkboxes. The modal window has an option to "cancel unchecking". Everything works so far but the conditional Group does not show up, when the checkbox is set with Javascript, depending of the Button-Click in the modal window.

I tried with ".trigger('change')" and ".change()" ... the conditional group does not show up but the checkbox is checked.

jQuery("input[name='wpcf-angaben-zu-starken']").prop('checked', true).trigger('change');

Of course I could set the groups visible but all forms are getting disabled and would't save (this was the main Reason for me to work on this modal, i didn't want the users to think this is a collapse function).

Is there a way to to hook in the conditional group controle? I really was thinking that i had the hard part of work done ...

#2249585

Hi,

Thank you for contacting us and I'd be happy to assist.

On my test website, I was able to make the checkbox linked to a conditional group trigger, using a custom script, like this:


jQuery( document ).ready(function() {
    jQuery( "a.link" ).click(function(event){
        event.preventDefault();
        jQuery( "input[name=wpcf-book-checkbox]" ).trigger('click');
    });
});

I included a custom link with class "link" and when it was clicked, it would also check the checkbox for the "book-checkbox" field, which in turn would show the linked conditional group too.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#2249605

Hi Waqar,

thank you for your quick reply. My Issue is resolved, you made my day.

Kinde regards
Fatih

#2249607

My issue is resolved now. Thank you!