protected function TripalFieldFormatter::ajaxifyPager

3.x TripalFieldFormatter.inc protected TripalFieldFormatter::ajaxifyPager($pager, $entity)

Updates a pager generated by theme('pager') for use with AJAX.

Because fields are meant to be updated by AJAX we need clicks in the pager to not reload the entire page but rather to only reload the field. Therefore the links in the pager must be adjusted to support this.

Parameters

$pager: The pager as created by theme('pager')

$entity: The entity object.

1 call to TripalFieldFormatter::ajaxifyPager()
sbo__relationship_formatter::view in tripal_chado/includes/TripalFields/sbo__relationship/sbo__relationship_formatter.inc

File

tripal/includes/TripalFields/TripalFieldFormatter.inc, line 189

Class

TripalFieldFormatter

Code

protected function ajaxifyPager($pager, $entity) {

  $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);
  $pager = preg_replace('/href="\/.+"/', 'href="javascript:void(0)" onclick="tripal_navigate_field_pager(\'' . $field_id . '\', 0)"', $pager);

  $pager = '<img src="/' . drupal_get_path('module', 'tripal') . '/theme/images/ajax-loader.gif" id="' . $field_id . '-spinner" class="tripal-field-ajax-spinner">' . $pager;
  return $pager;
}