I have a simple component that just pops up a browser alert if a specific field is filled in when the page finishes rendering. I'm not too familiar with the different DOM events and when they fire, but I am using render since load gave me an error. My hope is that I can just have the alert pop up when the page finishes loading, but not after every save. Is there a DOM event that would capture that? Or is there another good way to handle this?
<aura:handler name="render" value="{!this}" action="{!c.onRender}"/>
onRender : function(cmp, event) {
var myAccount = cmp.get("v.acc");
if(myAccount.Alert__c != null)
{
alert(myAccount.Alert__c);
}
}
Best Answer
If you are looking for firing it just once, You can keep a boolean property to check if page has loaded. Refer the property inside the onRender function to execute your code just once.