4

Is there a re-render event for lightning component? When a component is first rendered we can use init event to invoke init functions. Is there any event that can be handled when aura:renderIf condition is set to true after it was set to false in the following code snippet?

Init event

<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

Render If

    <aura:renderIf isTrue="{!v.showCatalog}">
            <c:Catalog id="{!v.id}" 
            products="{!v.products}" />
    </aura:renderIf>

2 Answers 2

1

This answer may help you: Lightning rerender a force:recordView

As of Summer '15 this component still has server-side dependencies that prevent it from updating as desired. You will need create the component in JavaScript to achieve the desired result. Here's a small app that demonstrates this:

<aura:application access="GLOBAL">
    <aura:attribute name="id" type="String" access="GLOBAL" default="001B0000003jUXI"/>
    <aura:handler name="change" value="{!v.id}" action="{!c.updateRecordView}"/>
    <div aura:id="container">
        <force:recordView recordID="{!v.id}" type="MINI"/>
    </div>
    <ui:inputText value="{!v.id}"/>
</aura:application>

And the controller code:

({
    updateRecordView: function(component, event, helper) {
        var id = component.get("v.id");
        var container = component.find("container");
        $A.createComponent("force:recordView",
                           {recordId: id,type: "MINI"},
                           function(cmp) {
                               container.set("v.body", [cmp]);
                           });
    }
})
2
  • I will try out change handler, although you can see my requirement has no change or record view in it. The catalog component might show information same as before or different based on user changes on other components.
    – dipu
    Jan 24, 2016 at 1:56
  • You should have googled a little more, I found this answer straight away here - sad to say that this is not a nice comment.
    – Raul
    Aug 12, 2021 at 8:44
0

One can use renderer.js in the lightning framework. Rerender is an inbuilt event provided within the renderer.js which gets fired whenever the component property modifies. Refer to this link for more information. https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_renderers.htm

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .