Skip Navigation

[Resolved] the Update to CRED 1.9 has prevented Jquery operating

This support ticket is created 6 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.

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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 15 replies, has 2 voices.

Last updated by Shane 6 years, 10 months ago.

Assisted by: Shane.

Author
Posts
#533890

I updated to CRED 1.9 and discovered that some JS code in my CRED form stopped working...

The code is to limit the number of selections of two custom fields. I wound back to an earlier version of CRED and the code started working again.

The code in question is as follows:

var countCheckedTopics = function() {
var nTopics = jQuery( "div.cred-taxonomy-category input:checked" ).length;
if( nTopics >= 3 ){
jQuery( "div.cred-taxonomy-category input[type=checkbox]" ).not( ":checked" ).prop({
disabled: true
});
} else {
jQuery( "div.cred-taxonomy-category input[type=checkbox]" ).not( ":checked" ).prop({
disabled: false
});
};
};
countCheckedTopics();

jQuery( "div.cred-taxonomy-category input[type=checkbox]" ).on( "click", countCheckedTopics );

var countCheckedTopics = function() {
var nTopics = jQuery( "div.cred-taxonomy-company-state input:checked" ).length;
if( nTopics >= 2 ){
jQuery( "div.cred-taxonomy-company-state input[type=checkbox]" ).not( ":checked" ).prop({
disabled: true
});
} else {
jQuery( "div.cred-taxonomy-company-state input[type=checkbox]" ).not( ":checked" ).prop({
disabled: false
});
};
};
countCheckedTopics();

jQuery( "div.cred-taxonomy-company-state input[type=checkbox]" ).on( "click", countCheckedTopics );

My site is again working fine so could you please let me know when you have resolved the problem so I can update the plugin.

Cheers

Peter

#533952

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Peter,

Thank you for contacting our support forum.

Is there a way I can see this on the frontend to see the errors and see why its not working ?

Maybe I can debug this to see why its not working.

Looking forward to hearing from you soon.

Thanks,
Shane

#534034

Sure Shane

Have a look at one of the forms I am now having a problem with... this is my staging site... I have again updated to Cred 1.9 and also the latest version of Types, released overnight.

hidden link

The checkboxes for Company type should be limited to 3 choices and 2 choices for the State field.

Cheers

Peter

#534482

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Peter,

It seems I need access to view this page.

Would you mind providing me with the admin access so that I can check for you ?

Thanks,
Shane

#537454

Ah silly me... you do need to be logged in... I have had a few more pressing issues to address...

Could you please re-enable private for my next reply? Will try to get to this later today.

Cheers

Peter

#537738

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Peter,

The private fields have been enabled.

Thanks,
Shane

#538707

Oops I still need help please

#539274

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screen Shot 2017-06-20 at 1.51.01 PM.png

Hi Peter,

I believe this isn't working because the code might be applied to the wrong element.

Take a look here see screenshot

The code is being applied to the div and not the ul. Could you try specifying the code to target the ul list and see if that helps.

Thanks,
Shane

#539394

Shane

I tried changing the code replacing references to ".div" to ".ul" but it didn't make any difference.... Not that I have any confidence in coding... the section of code I found on the internet and I may have had some assistance from your colleagues before...

BUT it works with the only version of CRED but not with 1.9... so I figured it was an issue with the new version of CRED and not the code.

I may have (probably did) stuff up the code changes

Could you perhaps have another look?

Cheers

Peter

the code as used is set out below:

var countCheckedTopics = function() {
var nTopics = jQuery( "ul.cred-taxonomy-category input:checked" ).length;
if( nTopics >= 3 ){
jQuery( "div.cred-taxonomy-category input[type=checkbox]" ).not( ":checked" ).prop({
disabled: true
});
} else {
jQuery( "ul.cred-taxonomy-category input[type=checkbox]" ).not( ":checked" ).prop({
disabled: false
});
};
};
countCheckedTopics();

jQuery( "ul.cred-taxonomy-category input[type=checkbox]" ).on( "click", countCheckedTopics );

var countCheckedTopics = function() {
var nTopics = jQuery( "ul.cred-taxonomy-company-state input:checked" ).length;
if( nTopics >= 2 ){
jQuery( "div.cred-taxonomy-company-state input[type=checkbox]" ).not( ":checked" ).prop({
disabled: true
});
} else {
jQuery( "ul.cred-taxonomy-company-state input[type=checkbox]" ).not( ":checked" ).prop({
disabled: false
});
};
};
countCheckedTopics();

jQuery( "ul.cred-taxonomy-company-state input[type=checkbox]" ).on( "click", countCheckedTopics );

#539889

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Peter,

I have some good news. I tested your original code and it seems to still work.

There might be some plugin conflict causing this issue, would you mind temporarily disabling all your non-toolset plugins and trying again as i'm observing a javascript error in the console for your website.

Looking forward to hearing from you soon about this.

Thanks,
Shane

#541040

Shane

I had composed a reply that I thought had been sent.

I tried what you suggested but it didn't work for me. I was still able to select any number of categories or company-state, rather than 3 and 2 respectively.

Peter

#541605

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Peter,

For further testing purposes, would you mind if I grab a duplicator package form the website ?

I would like to investigate further as to why this is not working.

Thanks,
Shane

#544157

Sorry for the delay

I cannot do Duplicator as I am hosted with WPengine..

I have been having troubles getting the all-in-one WP migration plugin to work... Trying again now.... can you set the next reply to private so I can send the files to you.

Cheers

Peter

#544253

I am now ready to upload the files... if you can set the reply to private.

#544316

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Petre,

The private fields have been enabled.

Thanks,
Shane

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