2

I have created & added 4 different components in Lightning page and I want to refresh all of them if any components records get change.

I know that, In order to refresh the specific component we can use $A.get('e.force:refreshView').fire(); event.

but how i can communicate refresh event from one components to another ?

  • Does force:refreshView not refresh the complete view? Are you saying the other 3 components are not updating when you trigger force:refreshview event? – Rao Jul 26 '17 at 16:49
  • There are indeed some components that do not handle force:refreshView. For example, if you have a custom component that creates a record in a community and also have a standard list view component on the same page, the list view will not listen to the event to update the records in the list after a new one is created. The only workaround we have found is to navigate away then back to force the framework to recreate the list view component. – dsharrison Jul 26 '17 at 16:55
  • Yes, force:refreshView is working for one components but not for the other component – kiran Jul 27 '17 at 2:27
4

You can listen to exact that event in another component, just add a handler:

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

As this is an application event all components declaring interest in handling this event will be notified, regardless who is dispatching the refresh view event

  • Does this mean that, there has to be one handler for every component to refresh every component inside an app? – Rao Jul 26 '17 at 17:07
  • 2
    Yes, every component must register a handler – Christian Menzinger Jul 26 '17 at 17:29
  • thanks for reply. can you explain how the other components will listen this action="{!c.onRefreshView}" ? can you please provide the example ? thanks – kiran Jul 27 '17 at 2:29
  • please post another question, however, i would suggest you read the lightning component developer guide and accept the answer if it helped you. thanks! – glls Jul 27 '17 at 2:47
  • Thanks Chris - I got the answer here. developer.salesforce.com/blogs/developer-relations/2015/07/… Intercomponent communication – kiran Jul 27 '17 at 3:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.