Reference and Name custom field renderers that don't link

  • 3
  • Idea
  • Updated 6 months ago
  • Implemented
These are in the community already but thought that new users should have it easily searchable by title. 

// this is the code that makes a non-reference field not link
skuid.snippet.registerSnippet('DontLink',function(args) {var field = arguments[0],
    value = skuid.utils.decodeHTML(arguments[1]);

    if (field.mode !== 'edit') {

        field.element.append(skuid.$('<div>').addClass('nx-fieldtext').text(value));
        
    // this code can be modified to meet the needs of the other modes
    } else {

        skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,value);
    }
});


// this is the code that makes a reference field not link
skuid.snippet.registerSnippet('refDontLink',function(args) {var field = arguments[0],
    value = skuid.utils.decodeHTML(arguments[1]);

    if (field.mode !== 'edit') {

        field.element.append(skuid.$('<div>').addClass('nx-fieldtext').text(field.model.getFieldValue(field.row,skuid.utils.getFieldReference(field.id,field.metadata))));
        
    // this code can be modified to meet the needs of the other modes
    } else {

        skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,value);
    }
});
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,764 Points 20k badge 2x thumb

Posted 3 years ago

  • 3
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,026 Points 20k badge 2x thumb
Thanks for setting up the individual post Pat. 
Photo of Robin

Robin

  • 894 Points 500 badge 2x thumb
Thank you for posting this here! Is there any reasonable explanation for why whenever I use a custom field renderer on one of my pages, all fields using the snippet get rendered correctly EXCEPT the first field on the page the snippet is applied to? Content just comes up as blank (doesn't matter if the field is in a table, field editor, calendar, deck). If I implement a "refresh" button on the page, the error is resolved and it gets rendered correctly. If I load the page "fresh" in the browser, or use the browser's "reload" function, the bug persists. 

Any suggestions are greatly appreciated!

Regards, 

Robin