Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. //Conditionally toggle metabox' visibility if other metabox' checkbox is checked
  2. function show_metaboxes_on_condition($checkbox, $toggled_box, inverse) {
  3. inverse = typeof inverse !== 'undefined' ? inverse : false;
  4. if ($checkbox.length && $toggled_box.length) {
  5. $toggled_box = $toggled_box.parents('.rwmb-field');
  6. $toggled_box.hide();
  7. if (inverse === false) {
  8. if ($checkbox.is(':checked')) {
  9. $toggled_box.show();
  10. }
  11. } else {
  12. if (!$checkbox.is(':checked')) {
  13. $toggled_box.show();
  14. }
  15. }
  16. $checkbox.on('change', function() {
  17. $toggled_box.toggle();
  18. });
  19. }
  20. }
  21.  
  22. show_metaboxes_on_condition($('#lmmb_languages_is_closed'), $('#lmmb_languages_start_month'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement