Преглед на файлове

Remove automatically attached fields that are empty

Abdullah Almsaeed преди 6 години
родител
ревизия
2fb3467a6b
променени са 1 файла, в които са добавени 12 реда и са изтрити 0 реда
  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);