Browse Source

Fixed bug with inconsistent setting of html ID for auto_attach fields

Stephen Ficklin 8 years ago
parent
commit
1e0095dbe9

+ 0 - 3
tripal/includes/TripalFields/TripalFieldFormatter.inc

@@ -172,9 +172,6 @@ class TripalFieldFormatter {
    */
   protected function ajaxifyPager($pager, $entity) {
 
-    global $base_path;
-
-    $tmp_base_path = preg_replace('/\//', '\/', $base_path);
     $field_id = 'tripal-entity-' . $entity->id . '--' . $this->field['field_name'];
 
     $pager = preg_replace('/href="\/.+\?page=(.+?)"/', 'href="javascript:void(0)" onclick="tripal_navigate_field_pager(\'' . $field_id . '\', $1)"', $pager);

+ 4 - 2
tripal/includes/tripal.entity.inc

@@ -328,11 +328,13 @@ function tripal_entity_view($entity, $type, $view_mode, $langcode) {
       // the field.
       $instance = field_info_instance('TripalEntity', $child_name, $entity->bundle);
       if ($instance and array_key_exists('settings', $instance)) {
+        $class = '';
         if (array_key_exists('auto_attach', $instance['settings']) and
             $instance['settings']['auto_attach'] == FALSE) {
-          $entity->content[$child_name]['#prefix'] .= '<div id="tripal-entity-' . $entity->id . '--' . $child_name . '" class="tripal-entity-unattached">';
-          $entity->content[$child_name]['#suffix'] .= '</div>';
+          $class = 'class="tripal-entity-unattached"';
         }
+        $entity->content[$child_name]['#prefix'] .= '<div id="tripal-entity-' . $entity->id . '--' . $child_name . '" ' . $class . '>';
+        $entity->content[$child_name]['#suffix'] .= '</div>';
       }
     }
   }

+ 7 - 6
tripal/theme/js/tripal.js

@@ -23,14 +23,15 @@
 
 })(jQuery);
 
+// Used for ajax update of fields by links in a pager.
 function tripal_navigate_field_pager(id, page) {
-    jQuery(document).ajaxStart(function () {
-      jQuery('#' + id + '-spinner').show();
-    }).ajaxComplete(function () {
-      jQuery('#' + id + '-spinner').hide();
-    });
+  jQuery(document).ajaxStart(function () {
+    jQuery('#' + id + '-spinner').show();
+  }).ajaxComplete(function () {
+    jQuery('#' + id + '-spinner').hide();
+  });
 
-    jQuery.ajax({
+  jQuery.ajax({
     type: "GET",
     url: Drupal.settings["basePath"] + "bio_data/ajax/field_attach/" + id,
     data: { 'page' : page },