When I am creating a list at js controller side I am adding hyperlink to 1 value, So while displaying the list on table that column will look like href.

lstApplications is wrapper list returned from server.
var allApps = [];
for(iterate lstApplications list){ //pseudo code
    var lstAppnByUser = {};
    lstAppnByUser["CreatedById"] = lstApplications[i].CreatedById;
    lstAppnByUser["CreatedByName"] = '<a href="javascript:void(0)" class="slds-text-link" onclick="{!c.applyFilter}">'+lstApplications[i].CreatedByName+'</a>';

the column td value looks like an link, which is correct, but on click of click I am getting below error in console.

Uncaught ReferenceError: c is not defined throws at https://communityURL ReferenceError: c is not defined at HTMLAnchorElement.onclick

The table is a reusable component, based on multiple list there can be link for different column, that's why I am adding a link while creating the list only.


for creating the HTML element dynamically you can refer to my answer here


you can refer to this code for creating the anchor(a) tag dynamically in your lightning component.

tag: "a", 
HTMLAttributes: {
"class": "slds-text-link",
              var container = cmp.find("container");
              if (container.isValid()) {
                  var body = container.get("v.body");
                  container.set("v.body", body);

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.