Explorar o código

Remove automatically attached fields that are empty

Abdullah Almsaeed %!s(int64=6) %!d(string=hai) anos
pai
achega
2fb3467a6b
Modificáronse 1 ficheiros con 12 adicións e 0 borrados
  1. 12 0
      tripal/theme/js/tripal.js

+ 12 - 0
tripal/theme/js/tripal.js

@@ -26,6 +26,17 @@
           field.load();
         }
       });
+
+      // Remove auto attached fields that are empty
+      if (hide_fields) {
+        $('.tripal_pane .field-items').each(function () {
+          console.log($(this).text().trim().length);
+          if ($(this).text().trim().length === 0) {
+            $(this).parents('tr').first().remove();
+            $(this).parents('.field').first().remove();
+          }
+        });
+      }
     }
   };
 
@@ -88,6 +99,7 @@
     var content = data['content'];
     var id      = data['id'];
     var field   = $('#' + id);
+    console.log(field);
     var classes = field.parents('.tripal_pane').first().attr('class').split(' ');
     var pane_id = this.extractPaneID(classes);
     $('#' + id + ' .field-items').replaceWith(content);