1

I want to convert {!'RaceName' + v.race.Name} to a hyperlink which should link to the built-in Salesforce edit page, I have tried to convert it into a hyperlink but it just didn't work?

<aura:component controller="RaceController">
<aura:attribute name="race" type="Race__C" />
<aura:attribute name="recordId" type="String" /> 
<header class="slds-card__header" >               
    <p class="slds-text-heading--label" >

        <a onclick="{!c.handleClick}"> {!'RaceName: ' + v.race.Name} </a></p>
</header>

above is my code and after the header, I have rest of the columns to show on the list page

I have a sobject Race__c and I have created a lightning component page to add and retrieve the value from this object. The list page where I have iterated all the records from that object I want to add a hyperlink to the name to open up its default record page. enter image description here

as showing in the above image I want to convert the RaceName as hyperlink which basically open ups its system default page. which is the below one enter image description here

now I am getting the below error

enter image description here

2

The redirection should be managed in your client side controller using a lightning navigation event.

Anchor Tag:

component.cmp

<aura:component>
    <aura:attribute name="recordId" type="String" />

    <p><a onclick="{!c.handleClick}">link to record</a></p>
</aura:component>

controller.js

/* navToRecordController.js */
({
    handleClick: function (component, event, helper) {
        var navEvt = $A.get("e.force:navigateToSObject");
        navEvt.setParams({
            "recordId": component.get("v.recordId")
        });
        navEvt.fire();
    }
})

As per the hyperlink not being highlighted as such, thats because you closed your anchor tag before adding the text from your variable binding.

  • I am very sorry for the confusion but I have updated my question, could please look into it again? – gs650x Jul 11 '18 at 16:53
  • Your update doesn’t change the answer, the redirection should still me manages client side, if you are unable to redirect, please update your question with your controller code and explain what difficulty you are experiencing – glls Jul 11 '18 at 16:56
  • I am using the same controller that you have mentioned above, but it's not changing that plain text to hyperlink – gs650x Jul 11 '18 at 17:00
  • well, thats because you closed your anchor tag before adding the text from your variable binding.... – glls Jul 11 '18 at 17:10
  • you should open a new post with the new error and behavior AND include your controller code – glls Jul 11 '18 at 17:25

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.