I have two lightning component placed on one page lightning app.
First Component have refresh icon and I set onclick action to refresh Component
$A.get('e.force:refreshView').fire();
but this event refresh the whole page instead of First component. how can refresh only one component on page not all the page ?
Best Answer
If you are refreshing the component from the context of a parent, you don't need to use an event - you can expose a
method
to the parent and get it to call that.If you are refreshing the component from within the child itself, you could either use an event or re-run your
init
routine.So for a parent calling a public
method
:The parent could get a reference to the child component and call
childComponent.reInit()
For a parent totally refreshing the child, the parent could dynamically recreate the component:
From the child component If you are doing this from within the component, you can despatch an event to the parent if you want a total refresh, or run the
reInit
method yourself.You can define a new
COMPONENT
event fire it to tell the parent that you want to be refreshed.In the child component:
In the parent component:
In the parent helper, the same code as above could be called - in the parent calling a public method section