Wordpress/Jquery - conditionally toggle metabox visibility in admin if other metabox checkbox is checked
//Conditionally toggle metabox' visibility if other metabox' checkbox is checked
function show_metaboxes_on_condition($checkbox, $toggled_box, inverse) {
inverse = typeof inverse !== 'undefined' ? inverse : false;
if ($checkbox.length && $toggled_box.length) {
$toggled_box = $toggled_box.parents('.rwmb-field');
$toggled_box.hide();
if (inverse === false) {
if ($checkbox.is(':checked')) {
$toggled_box.show();
}
} else {
if (!$checkbox.is(':checked')) {
$toggled_box.show();
}
}
$checkbox.on('change', function() {
$toggled_box.toggle();
});
}
}
show_metaboxes_on_condition($('#lmmb_languages_is_closed'), $('#lmmb_languages_start_month'));