i have a javascript function that i wish to run after the component is loaded. this is the function:

higlightCurrentRecordId : function(component, event, helper) {
    var id=component.get("v.idforHighlight");   

    var e=document.getElementById(id);    

    var node = document.createElement('div');        
    node.innerHTML = '<label class = "redDot" >&#9679;</label>';       

how can i trigger this function after the component is done loading?

please advise


you may use Afterrender In RENDERER Section

afterRender: function(component, helper) {

You can call this method either on aura:doneRendering or aura:valueInit. doneRendering is called everytime anything changes on your screen, even resizing. valueInit is called only on loading completion. so its upto your requirement which one to use.


<aura:handler event="aura:doneRendering" action="{!c.higlightCurrentRecordId}"/>


<aura:handler name="init" value="{!this}" action="{!c.higlightCurrentRecordId}"/>
  • Thank you. seems like i need to use the aura:valueInit but when i do i get the error: Uncaught Action failed: c:AccountRow$controller$higlightCurrentRecordId [Cannot read property 'appendChild' of null] and its not because there isn't a record as such, it just doesn't load i guess before valueInit starts. to test it, i added a button and whenever i press it, it works – Dana Griff Apr 3 '17 at 8:36

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.