0

I have created a lightning component for a lightning page. After the final save method, I am able to refresh another related list in the lightning page using 'e.force:refreshView' but I am not able to find any way to reload my custom lightning component? Is there any standard way of doing that? Thanks

1 Answer 1

1

Add a handler in your Lightning component for the event force:refreshView and then call you init method as an action on this handler.

<aura:handler event="force:refreshView" action="{!c.doInit}" />

Hope this will help.

4
  • 1
    But this will just execute the init method and won't reset the value of attributes, won't reload the DOM. Feb 13, 2019 at 10:24
  • @TejenderMohan As there is no standard way to refresh a component. Here you can create a function named refresh, and reinitialize all the attribute in the function. Call this function from the above handler instead of doInit Something like -- <aura:handler event="force:refreshView" action="{!c.refresh}" /> Feb 13, 2019 at 11:31
  • Hey Avinash Thanks (y) Can you please share a way to reinitialize object list type attribute? Feb 18, 2019 at 5:55
  • Just initialize with empty quotes, that will work.. Example : <aura:attribute name="msg" type="String"/> <aura:attribute name="ContactList" type="List"/> reinitialize these by ... component.set("v.msg",""); component.set("v.ContactList",""); Feb 18, 2019 at 6:48

You must log in to answer this question.

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