2

I need to rerender a component when an attribute value is changed. I tried to put the init handler code into a helper function and called it in valueChange event handler but it did not work. Please give me some suggestions.

<!--Handler-->
<aura:handler name="change" value="{!v.dfButtonId}" action="{!c.dfButtonIdChange}"/>

<!--js controller-->
doInit: function(component, event, helper){
    //This code is working correctly
},
dfButtonIdChange:function(component, event, helper){
   //I need to rerender the component here
}
8
  • Similar question salesforce.stackexchange.com/questions/122297/… Commented Jan 9, 2017 at 12:16
  • Did you get an error? Would you be willing to share some code that demonstrates it not working? Commented Jan 9, 2017 at 12:20
  • @sfdcfox the code is working correctly but I am not able to rerender the component when the value is changed. I tried refreshView but it refreshes everything which is currently in the view. Commented Jan 9, 2017 at 12:33
  • What is dfButtonId? Commented Jan 9, 2017 at 12:36
  • What are you trying to rerender? Some more information about what happens in the dfButtonIdChange function would be helpful. Commented Jan 9, 2017 at 12:57

1 Answer 1

3

The framework will detect any attribute changes automatically and rerender dirty values so you shouldn't need to manually track and rerender.

5
  • This was true for me up until now. I am changing attributes present directly in markup in <aura:if > but nothing is rerendering. I don't know why. Any idea? Commented Feb 1, 2017 at 14:49
  • Do you have a more complete example? Commented Feb 1, 2017 at 19:25
  • 1
    We have a case where this is happening. We are creating two arrays with references of objects. We are then dynamically creating components to display each item in those arrays. If we update a value in the original object and print out the value from component.get('v.myarray'), the value is updated in the array. However, the DOM doesn't get updated with the new value. Because of this we are trying to figure out a way to force a refresh. Commented Jan 23, 2018 at 20:43
  • @dsharrison I have the same issue - did you ever find out a solution? Commented Jun 19, 2018 at 14:16
  • @dharrison - i've got the same issue as well my components are next in 2 aura if's dont know if that has something to do with it Commented Mar 20, 2019 at 21:53

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.