Newer Version Available

This content describes an older version of this product. View Latest

aura:doneRendering

Indicates that the initial rendering of the root application or root component has completed.
This event is automatically fired if no more components need to be rendered or rerendered due to any attribute value changes. The aura:doneRendering event is handled by a client-side controller. A component can have only one <aura:handler event="doneRendering"> tag to handle this event.
1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<aura:handler event="aura:doneRendering" action="{!c.doneRendering}"/>
For example, you want to customize the behavior of your app after it’s finished rendering the first time but not after subsequent rerenderings. Create an attribute to determine if it’s the first rendering.
1swfobject.registerObject("clippy.codeblock-1", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<aura:component>
18    <aura:handler event="aura:doneRendering" action="{!c.doneRendering}"/>
19    <aura:attribute name="isDoneRendering" type="Boolean" default="false"/>
20    <!-- Other component markup here -->
21    <p>My component</p>
22</aura:component>
This client-side controller checks that the aura:doneRendering event has been fired only once.
1swfobject.registerObject("clippy.codeblock-2", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17({
18  doneRendering: function(cmp, event, helper) {
19    if(!cmp.get("v.isDoneRendering")){
20      cmp.set("v.isDoneRendering", true);
21      //do something after component is first rendered
22    }
23  }
24})

When aura:doneRendering is fired, component.isRendered() returns true. To check if your element is visible in the DOM, use utilities such as component.getElement(), component.hasClass(), or element.style.display.

Note

The aura:doneRendering handler contains these required attributes.
Attribute Name Type Description
event String The name of the event, which must be set to aura:doneRendering.
action Object The client-side controller action that handles the event.