Skip to content

Commit aba07fc

Browse files
authored
gppa-remove-empty-checkbox-choices.js: Updated snippet name to gppa-remove-empty-choices.js and added support for Radio Buttons.
1 parent 6af9e60 commit aba07fc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

gp-populate-anything/gppa-remove-empty-checkbox-choices.js renamed to gp-populate-anything/gppa-remove-empty-choices.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
/**
2-
* Gravity Perks // Populate Anything // Remove Empty Checkbox Choices
2+
* Gravity Perks // Populate Anything // Remove Empty Choices
33
* https://gravitywiz.com/documentation/gravity-forms-populate-anything/
44
*
55
* 1. Install this snippet with our free Custom JavaScript plugin.
66
* https://gravitywiz.com/gravity-forms-custom-javascript/
77
*/
88

9-
var $containers = $( '.gfield_checkbox' );
9+
var $containers = $( '.gfield--type-choice' );
1010

1111
// On page load.
1212
$containers.each( function() {
13-
gwizRemoveEmptyCheckboxes( $( this ) );
13+
gwizRemoveEmptyChoices( $( this ) );
1414
} );
1515

1616
// Show/hide checkboxes when the field is manipulated.
1717
$containers.bind( 'DOMNodeInserted DOMNodeRemoved', function() {
18-
gwizRemoveEmptyCheckboxes( $( this ) );
18+
gwizRemoveEmptyChoices( $( this ) );
1919
} );
2020

21-
function gwizRemoveEmptyCheckboxes( $elem ) {
22-
$elem.find( 'input[type="checkbox"]' ).each( function() {
21+
function gwizRemoveEmptyChoices( $elem ) {
22+
$elem.find( 'input[type="checkbox"], input[type="radio"]' ).each( function() {
2323
if( ! $( this ).val() ) {
2424
$( this ).parent().hide();
2525
}

0 commit comments

Comments
 (0)