Last active
October 15, 2019 23:10
-
-
Save garretthyder/260986880eb1095cb0436efae09351f0 to your computer and use it in GitHub Desktop.
Enable Support for Required Intl-Tel fields in Groups that are conditionally shown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Support ACF Intl Tel Address when in conditional group | |
jQuery(document).ready(function ($) { | |
$('[data-hiddeninput]').each(function() { | |
if ( $(this).is(":visible") ) { | |
$(this).prop('disabled', false); | |
$(this).removeAttr('disabled'); | |
} else { | |
$(this).prop('disabled'); | |
$(this).attr('disabled', 'disabled'); | |
} | |
}); | |
acf.addAction("enable_field/type=group", function( field ) { | |
field.$el.find('[data-hiddeninput]').prop('disabled', false); | |
field.$el.find('[data-hiddeninput]').removeAttr('disabled'); | |
}); | |
acf.addAction("disable_field/type=group", function( field ) { | |
field.$el.find('[data-hiddeninput]').prop('disabled'); | |
field.$el.find('[data-hiddeninput]').attr('disabled', 'disabled'); | |
}); | |
acf.addAction("append_field/type=group", function( field ) { | |
field.$el.find('[data-hiddeninput]').prop('disabled', false); | |
field.$el.find('[data-hiddeninput]').removeAttr('disabled'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to account for Repeaters