1

I tried hiding the edit, delete, enable and disable links in contact relationships writing an extension in the hook _civicrm_alterContent and injecting jquery:

  $content= $content . "
    <script type='text/javascript'>
      CRM.$(document).ready(
        function($) {
          $( '.crm-contact-relationship-links span a:nth-child(2)' ).remove();
          $( '.crm-contact-relationship-links span:nth-child(2)' ).remove();
        }
      );
    </script>
  ";

The data I want to hide is supplied through Ajax and apparently out of Jquery's reach because I don't see the desired effect.

Then I tried it using the dataTable API:

        <script type='text/javascript'>

      CRM.$(document).ready(
        function($) {
          var table = $('table.crm-contact-relationship-selector-current').DataTable();
          table.$( '.crm-contact-relationship-links span a:nth-child(2)' ).remove();
          table.$( '.crm-contact-relationship-links span:nth-child(2)' ).remove();
        }
      );
    </script>

Without success!

Any suggestion to still reach my goal?

2

Please see the Civi JavaScript reference , specially this:

CRM.$(function($) {

// Your code here

 });

Remember that CRM.$ is our alias of jQuery. So the first line is shorthand notation for CRM.$('document').ready(function($) { The function receives jQuery as it's param, so now we have access to jQuery as the familiar $ for use in our code.

Also make sure you are targeting the right template: CRM/Contact/Page/View/RelationshipSelector.tpl

A different approach would be to create a custom template as explained here and disable the actions links based on $context

Update: according to dataTable API, you could do this:

CRM.$(function($) {
    var table = $('table.crm-contact-relationship-selector-current').DataTable();
    var column = table.column('.crm-contact-relationship-links');
    column.visible( false );
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.