function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rahul Singh 1384Rahul Singh 1384 

Reload a div on the click of a button in lightning component

I have to refresh a div in a Lightning Component, the same as how we use rerender in a Visualforce Page. How can I do so?
Prakash NawalePrakash Nawale
Rahul,

You can use Aura: if se componet to rerender the elements.
e.g.  <aura:if isTrue="{!v.showDiv}">
        <div> Logic here </div
    </aura:if>

set the showDiv property value from js controller
Swapnil KambleSwapnil Kamble
Hi Rahul, you can also use timeout.

Component
<lightning:button variant="brand" label="Self Rerender" onclick="{! c.reload }" />
<aura:attribute name="truthy" type="boolean" default="true" />
<aura:renderIf isTrue="{!v.truthy}">
       your div
</aura:renderIf>

controller.js
reload : function(component, helper){
        component.set("v.truthy",false);
        window.setTimeout(
            $A.getCallback(function() {
                component.set("v.truthy",true)
            })
            ,1000);
 }

 
Dhaker HassineDhaker Hassine

Hello Swapnil Kamble, 

I tried your code for my example, and after the click the two divs hide, and only the first div (just text to test) that reappeared, but the second one don't. what's the problem there? 

Ps: the second one is full calendar
 

<aura:renderIf isTrue="{!v.truthy}">
             <div> Salut je teste ici</div>
            <div id='calendar'></div>
        </aura:renderIf>