+ 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

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

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

<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

reload : function(component, helper){
            $A.getCallback(function() {

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>