0

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>';
allApps.push(lstAppnByUser);
}
component.set("v.lstAllApplns",allApps);

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.

0

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

OR

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

$A.createComponent(
"aura:HTML", 
{ 
tag: "a", 
HTMLAttributes: {
"id":"any_id",
"class": "slds-text-link",
"href":"javascript:void(0);",
"onclick":component.getReference("c.applyFilter")}},
         function(compo){
              var container = cmp.find("container");
              if (container.isValid()) {
                  var body = container.get("v.body");
                  body.push(compo);
                  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.